Skip to content

Commit

Permalink
Merge pull request #45 from mapsme/fix_is_accurate
Browse files Browse the repository at this point in the history
Update ccode.py
  • Loading branch information
thaelathy authored Nov 5, 2019
2 parents 4257e06 + 9560314 commit c00fbe5
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions snippets/pyaloha/ccode.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,26 +41,28 @@ class PythonEventTime(object):
delta_future = 1 * msec_in_a_day

def __init__(self, server_dtime, client_dtime):
if client_dtime < server_dtime - self.delta_past or\
client_dtime > server_dtime + self.delta_future:
dtime = server_dtime
else:
dtime = client_dtime

self.client_creation = client_dtime
self.server_upload = server_dtime

if self.is_accurate:
dtime = client_dtime
else:
dtime = server_dtime

self.dtime = SerializableDatetime.utcfromtimestamp(
dtime / 1000. # timestamp is in millisecs
)

@property
def is_accurate(self):
return self.dtime == self.client_creation
if self.client_creation > self.server_upload - self.delta_past and\
self.client_creation < self.server_upload + self.delta_future:
return True
return False

def __dumpdict__(self):
return {
'dtime': self.dtime,
'is_accurate': self.is_accurate
'dtime': self.dtime
}


Expand Down

0 comments on commit c00fbe5

Please sign in to comment.