[Python-checkins] CVS: python/nondist/sandbox/datetime
datetime.py,1.16,1.17 test_datetime.py,1.11,1.12
Tim Peters
tim.one@comcast.net
Sat, 02 Mar 2002 22:35:39 -0500
- Previous message: [Python-checkins] CVS: python/nondist/sandbox/datetime datetime.py,1.16,1.17 test_datetime.py,1.11,1.12
- Next message: [Python-checkins] CVS: python/dist/src/Modules _hotshot.c,1.14,1.15 dbmmodule.c,2.28,2.29 fcntlmodule.c,2.33,2.34 main.c,1.63,1.64 pwdmodule.c,1.27,1.28 readline.c,2.43,2.44 selectmodule.c,2.60,2.61 signalmodule.c,2.62,2.63 termios.c,2.33,2.34 timemodule.c,2.122,2.123 unicodedata.c,2.14,2.15
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
> def weekday(self):
> "Return day of the week, where Monday == 0 (according to ISO)."
> # The constant 6 was obtained experimentally :-)
> return (_ymd2ord(self.__year, self.__month, self.__day) + 6) % 7
I'm not sure why we're mucking with the ISO calendar too, but if we want to
then I believe this function is incorrect. According to ISO 8601
http://www.pvv.org/~nsaa/8601v2000.pdf
section 4.3.2.2 says ISO day ordinals are from 1 (Monday) through 7
(Sunday).
"Day 1" in the proleptic Gregorian system is a Monday, so
return self.toordinal() % 7 or 7
implements the ISO rule.
> def isocalendar(self):
> """Return a 3-tuple containing ISO year, week number,
> and weekday.
Why <0.7 wink>?
- Previous message: [Python-checkins] CVS: python/nondist/sandbox/datetime datetime.py,1.16,1.17 test_datetime.py,1.11,1.12
- Next message: [Python-checkins] CVS: python/dist/src/Modules _hotshot.c,1.14,1.15 dbmmodule.c,2.28,2.29 fcntlmodule.c,2.33,2.34 main.c,1.63,1.64 pwdmodule.c,1.27,1.28 readline.c,2.43,2.44 selectmodule.c,2.60,2.61 signalmodule.c,2.62,2.63 termios.c,2.33,2.34 timemodule.c,2.122,2.123 unicodedata.c,2.14,2.15
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]