Message226226
timestamp() method works correctly for an aware datetime objects
as in my example (notice: timezone.utc in the code).
The issue is not that it is a manual computation,
the issue is that it is incorrect:
#XXX WRONG, DO NOT DO IT
time.mktime(datetime.datetime.utcnow().timetuple())
On older Python versions, given a utc time as a naive datetime
object, POSIX timestamp is:
ts = (utc_dt - datetime(1970, 1, 1)).total_seconds()
utc_dt = datetime(1970, 1, 1) + timedelta(seconds=ts) # in reverse |
|
Date |
User |
Action |
Args |
2014-09-01 12:36:55 | akira | set | recipients:
+ akira, terry.reedy, pitrou, regu0004 |
2014-09-01 12:36:55 | akira | set | messageid: <1409575015.01.0.789639886282.issue22296@psf.upfronthosting.co.za> |
2014-09-01 12:36:54 | akira | link | issue22296 messages |
2014-09-01 12:36:54 | akira | create | |
|