[issue10827] Functions in time module should support year < 1900 when accept2dyear = 0
Alexander Belopolsky
report at bugs.python.org
Fri Jan 7 01:57:17 CET 2011
Alexander Belopolsky <belopolsky at users.sourceforge.net> added the comment:
Attached patch, issue10827c.diff, implements the following logic in gettmarg:
/* If year is specified with less that 4 digits, its interpretation
* depends on the accept2dyear value.
*
* If accept2dyear is true (default), a backward compatibility behavior is
* invoked as follows:
*
* - for 2-digit year, century is guessed according to POSIX rules for
* %y strptime format: 21st century for y < 69, 20th century
* otherwise. A deprecation warning is issued when century
* information is guessed in this way.
*
* - for 3-digit or negative year, a ValueError exception is raised.
*
* If accept2dyear is false (set by the program or as a result of a
* non-empty value assigned to PYTHONY2K environment variable) all year
* values are interpreted as given.
*/
It is easy to restore year >= 1900 limit for strftime, but I would rather add tests that time.strftime either produces correct values or raises ValueError and see if buildbots discover any platform bugs.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue10827>
_______________________________________
More information about the Python-bugs-list
mailing list