]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Python's strftime implementation does strange things with the year,
authorTim Peters <tim.peters@gmail.com>
Sun, 22 Dec 2002 20:34:46 +0000 (20:34 +0000)
committerTim Peters <tim.peters@gmail.com>
Sun, 22 Dec 2002 20:34:46 +0000 (20:34 +0000)
such that the datetime tests failed if the envar PYTHON2K was set.
This is an utter mess, and the datetime module's strftime functions
inherit it.  I suspect that, regardless of the PYTHON2K setting, and
regardless of platform limitations, the datetime strftime wrappers
will end up delivering nonsense results (or bogus exceptions) for
any year before 1900.  I should probably just refuse to accept years
earlier than that -- else we'll have to implement strftime() by hand.

Modules/datetimemodule.c

index 73c17643a521c693cd8ebe4711547c64f17eb065..28f61bd29db40098a5c30d63a7c54be071144748 100644 (file)
@@ -3518,8 +3518,12 @@ time_strftime(PyDateTime_Time *self, PyObject *args, PyObject *kw)
                                          &PyString_Type, &format))
                return NULL;
 
+       /* Python's strftime does insane things with the year part of the
+        * timetuple.  The year is forced to (the otherwise nonsensical)
+        * 1900 to worm around that.
+        */
        tuple = Py_BuildValue("iiiiiiiii",
-                             0, 0, 0, /* year, month, day */
+                             1900, 0, 0, /* year, month, day */
                              TIME_GET_HOUR(self),
                              TIME_GET_MINUTE(self),
                              TIME_GET_SECOND(self),