Issue39103
Created on 2019-12-20 05:32 by jaraco, last changed 2022-04-11 14:59 by admin. This issue is now closed.
| Messages (3) | |||
|---|---|---|---|
| msg358695 - (view) | Author: Jason R. Coombs (jaraco) * ![]() |
Date: 2019-12-20 05:32 | |
On Python 3.8, there's a difference between how datetime.datetime.strftime renders %Y for years < 1000 between Linux and other platforms.
# Linux
$ docker run -it python python -c 'import datetime; print(datetime.date(900,1,1).strftime("%Y"))'
900
# macOS
$ python -c 'import datetime; print(datetime.date(900,1,1).strftime("%Y"))'
0900
According to the docs (https://docs.python.org/3/library/datetime.html#strftime-strptime-behavior), one should expect `'0000'` for year zero and so I'd expect `'0900'` for the year 900, so the macOS behavior looks correct to me.
|
|||
| msg358721 - (view) | Author: Brett Cannon (brett.cannon) * ![]() |
Date: 2019-12-20 17:37 | |
Due note, though, that there's a difference in the implementation of strftime versus strptime, as the former (at least the last time I looked ages ago) uses the libc version of the function and thus probably doesn't try to smooth out differences like this, while the latter is implemented in Python code in the stdlib itself. |
|||
| msg358735 - (view) | Author: Paul Ganssle (p-ganssle) * ![]() |
Date: 2019-12-20 19:34 | |
This is a duplicate of issue 13305. Right now we have some shims around `strftime` to improve consistency in some situations and for other reasons, but mostly we just call the libc version. There is an open issue from 2008 (#3173) to ship our own implementation of strftime that could smooth out some of these issues and try and make the behavior more consistent (though presumably some people have started to rely on platform-specific behaviors by now, so it may be a decent amount of work to roll it out). I'm going to close this in favor of 13305, but thanks for reporting it! |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:59:24 | admin | set | github: 83284 |
| 2019-12-20 19:34:12 | p-ganssle | set | status: open -> closed superseder: datetime.strftime("%Y") not consistent for years < 1000 messages: + msg358735 type: behavior |
| 2019-12-20 17:37:54 | brett.cannon | set | nosy:
+ brett.cannon messages: + msg358721 |
| 2019-12-20 06:21:30 | xtreak | set | nosy:
+ belopolsky, p-ganssle |
| 2019-12-20 05:32:00 | jaraco | create | |
