Author akira
Recipients Daniel.O'Connor, akira, belopolsky, bignose, mumino, r.david.murray, santoso.wijaya, tim.peters, vstinner
Date 2014-06-29.17:58:05
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1404064685.6.0.0698458958122.issue12750@psf.upfronthosting.co.za>
In-reply-to
Content
> 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
History
Date User Action Args
2014-06-29 17:58:05akirasetrecipients: + akira, tim.peters, belopolsky, vstinner, r.david.murray, santoso.wijaya, bignose, Daniel.O'Connor, mumino
2014-06-29 17:58:05akirasetmessageid: <1404064685.6.0.0698458958122.issue12750@psf.upfronthosting.co.za>
2014-06-29 17:58:05akiralinkissue12750 messages
2014-06-29 17:58:05akiracreate