Message221868
> Can you explain why math.floor rather than builtin round is the correct function to use?
To avoid breaking existing scripts that use `.strftime('%s')` on Linux, OSX,
see msg221385:
>>> from datetime import datetime, timezone
>>> dt = datetime(1969, 1, 1, 0,0,0, 600000, tzinfo=timezone.utc)
>>> '%d' % dt.timestamp()
'-31535999'
>>> round(dt.timestamp())
-31535999
>>> dt.astimezone().strftime('%s') # <-- existing behavior
'-31536000'
>>> '%d' % math.floor(dt.timestamp())
'-31536000'
>>> import calendar
>>> calendar.timegm(dt.astimezone(timezone.utc).timetuple())
-31536000 |
|
Date |
User |
Action |
Args |
2014-06-29 17:58:05 | akira | set | recipients:
+ akira, tim.peters, belopolsky, vstinner, r.david.murray, santoso.wijaya, bignose, Daniel.O'Connor, mumino |
2014-06-29 17:58:05 | akira | set | messageid: <1404064685.6.0.0698458958122.issue12750@psf.upfronthosting.co.za> |
2014-06-29 17:58:05 | akira | link | issue12750 messages |
2014-06-29 17:58:05 | akira | create | |
|