[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


>     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>?