~ubuntu-branches/ubuntu/precise/bittornado/precise

« back to all changes in this revision

Viewing changes to .pc/09_timtuckerfixes.dpatch/BitTornado/clock.py

  • Committer: Barry Warsaw
  • Date: 2011-08-10 23:17:46 UTC
  • mfrom: (7.1.1 bittornado)
  • Revision ID: barry@python.org-20110810231746-5buiob6p54m266s8
Tags: 0.3.18-10ubuntu2
* switch to dh_python2 (LP: #788514)
  - install btmakemetafile.py and btcompletedir.py via pyinstall
  - add build depend on python-all
  - bump debhelper depend to 7 for dh_auto_install

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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()
 
 
b'\\ No newline at end of file'