]> git.ipfire.org Git - people/shoehn/ipfire.org.git/blob - www/pages/torrent/client/clock.py
Change Color of Menuitem CeBIT.
[people/shoehn/ipfire.org.git] / www / pages / torrent / client / clock.py
1 # Written by John Hoffman
2 # see LICENSE.txt for license information
3
4 from time import *
5 import sys
6
7 _MAXFORWARD = 100
8 _FUDGE = 1
9
10 class RelativeTime:
11 def __init__(self):
12 self.time = time()
13 self.offset = 0
14
15 def get_time(self):
16 t = time() + self.offset
17 if t < self.time or t > self.time + _MAXFORWARD:
18 self.time += _FUDGE
19 self.offset += self.time - t
20 return self.time
21 self.time = t
22 return t
23
24 if sys.platform != 'win32':
25 _RTIME = RelativeTime()
26 def clock():
27 return _RTIME.get_time()