Move datetime to timestamp conversion in an OS-safe way
Closed this issue · 1 comments
gouthambs commented
I noticed you use 'date': int(now.strftime('%s'))
in your TrackUsage.after_request()
method. Though this version of converting datetime
to timestamp
is not supported officially. I actually get errors when I run in Windows.
I was thinking of moving to, import time; time.mktime(now.timetuple())
.
ashcrow commented
>>> import datetime
>>> import time
>>> n = datetime.datetime.utcnow()
>>> int(time.mktime(n.timetuple())) == int(n.strftime('%s'))
True
>>>
Looks like a good replacement! 👍