Project

General

Profile

« Previous | Next » 

Revision 1041

dates.py: Fixed timestamp() to deal with microseconds correctly by adding them after time.mktime()

View differences:

lib/dates.py
16 16
def from_timestamp(utc_timestamp):
17 17
    return naive2utc(datetime.datetime.utcfromtimestamp(utc_timestamp))
18 18

  
19
def timestamp(datetime_): return time.mktime(aware2local(datetime_).timetuple())
19
def timestamp(datetime_):
20
    datetime_ = aware2local(datetime_)
21
    return int(time.mktime(datetime_.timetuple())) + datetime_.microsecond/1e6
20 22

  
21 23
epoch = from_timestamp(0)
22 24

  

Also available in: Unified diff