[Python-checkins] python/nondist/sandbox/datetime datetime.py,1.118,1.119 doc.txt,1.65,1.66
tim_one@users.sourceforge.net
tim_one@users.sourceforge.net
2002年12月22日 12:32:56 -0800
Update of /cvsroot/python/python/nondist/sandbox/datetime
In directory sc8-pr-cvs1:/tmp/cvs-serv32023
Modified Files:
datetime.py doc.txt
Log Message:
Python's strftime implementation does strange things with the year,
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.
Index: datetime.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/datetime/datetime.py,v
retrieving revision 1.118
retrieving revision 1.119
diff -C2 -d -r1.118 -r1.119
*** datetime.py 22 Dec 2002 01:43:13 -0000 1.118
--- datetime.py 22 Dec 2002 20:32:53 -0000 1.119
***************
*** 912,916 ****
to underlying strftime should not be used.
"""
! timetuple = (0, 0, 0,
self.__hour, self.__minute, self.__second,
0, 0, -1)
--- 912,918 ----
to underlying strftime should not be used.
"""
! # The year must be >= 1900 else Python's strftime implementation
! # can raise a bogus exception.
! timetuple = (1900, 0, 0,
self.__hour, self.__minute, self.__second,
0, 0, -1)
Index: doc.txt
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/datetime/doc.txt,v
retrieving revision 1.65
retrieving revision 1.66
diff -C2 -d -r1.65 -r1.66
*** doc.txt 22 Dec 2002 19:52:45 -0000 1.65
--- doc.txt 22 Dec 2002 20:32:53 -0000 1.66
***************
*** 160,165 ****
For time and timetz objects, format codes for year, month, and day
! should not be used, as time objects have no such values. 0 is used
! instead.
For date objects, format codes for hours, minutes, and seconds should
--- 160,165 ----
For time and timetz objects, format codes for year, month, and day
! should not be used, as time objects have no such values. 1900 is
! used for the year, and 0 for the month and day.
For date objects, format codes for hours, minutes, and seconds should
***************
*** 189,195 ****
The exact range of years for which strftime() works also varies
! across platforms. For example, Microsoft's implementation of
! strftime() refuses to accept years before 1900, and Python inherits
! this limitation.
--- 189,195 ----
The exact range of years for which strftime() works also varies
! across platforms, and years before 1900 cannot be used on any
! platform if the environment variable PYTHON2K is set (see the
! documentation for Python's time module).