[docs] [issue13305] datetime.strftime("%Y") not consistent for years < 1000
report at bugs.python.org
Sun Jan 3 01:20:49 EST 2016
Ezio Melotti added the comment:
> Also, using %4Y seems to consistently produce zero-padded values across
> different platforms.
Actually I was wrong. Based on some more testing I did on Linux and Windows 8 and the previous comments in this thread, it seems that, with 1 as year:
* '%4Y' does produces '0001' on Linux but gives a value error on Windows and '4Y' on OS X;
* '%Y' produces '1' on Linux and '0001' on Windows and OS X;
So the problem is only on Linux and only with years <1000, where to have a zero-padded value %4Y can be used instead.
I don't know if these results are true for all versions of Linux/Win/OSX, so the note could just say that:
1) some platforms (e.g. Linux) don't zero-pad years <1000;
2) some platforms (e.g. Linux) support %4Y to add padding, but this doesn't work on other platforms.
Python tracker <report at bugs.python.org>
More information about the docs