This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: odd result for datetime.time.strftime("%s")
Type: behavior Stage: resolved
Components: Extension Modules Versions: Python 3.4, Python 2.7
process
Status: closed Resolution: duplicate
Dependencies: Superseder: add cross-platform support for %s strftime-format code
View: 12750
Assigned To: Nosy List: Dima.Tisnek, r.david.murray
Priority: normal Keywords:

Created on 2014-09-01 10:03 by Dima.Tisnek, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (2)
msg226224 - (view) Author: Dima Tisnek (Dima.Tisnek) * Date: 2014-09-01 10:03
$ python2 -c 'import datetime; print datetime.time(10, 44, 11).strftime("%s")'
-2208955189

$ python3 -c 'import datetime; print (datetime.time(10, 44, 11).strftime("%s"))'
-2208955189

So apparently, datetime.time(...).strftime("%s") semantically "seconds since unix epoch" assumes Jan 1, 1900 for missing date part.

However datetime module doesn't allow subtracting time objects, i.e. no assumption of date is made, where "same date" chould be reasonable.
msg226231 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2014-09-01 16:13
I believe this is effectively a duplicate of issue 12750.  That is, python doesn't do anything in particular with %s, it just lets the platform do what it will.  Issue 12750 is about making what it does consistent and cross-platform.

(On gentoo linux I get -1 from your examples for both python2 and python3.)

You should any any further comments to issue 12750.
History
Date User Action Args
2022-04-11 14:58:07adminsetgithub: 66517
2014-09-01 16:13:24r.david.murraysetstatus: open -> closed

superseder: add cross-platform support for %s strftime-format code

nosy: + r.david.murray
messages: + msg226231
resolution: duplicate
stage: resolved
2014-09-01 10:03:22Dima.Tisnekcreate