Can anyone tell me why time.gmtime() (and time.localtime()) use the
convention that Monday=0, rather than Sunday=0? The Sunday=0 convention
is used by C's gmtime(3), as well as both C and Python's strftime().
Oh, and Python's strptime() uses Monday=0 also, but C's uses Sunday=0.
Here's the relevant code from tmtotuple() in python-1.5.2/Modules/timemodule.c,
line 262:
(p->tm_wday + 6) % 7, /* Want Monday == 0 */
Why does Python go out of its way to be inconsistant, both with itself
and with C? (Or have I missed something here?)
Any enlightenment would be appreciated.
Tim.
--
Tim Bell - bh...@cs.mu.oz.au - Dept of Comp Sci & SE - Uni of Melbourne, Aust.
Is this a misfeature of python, inspired by the desire of making every
sequence starting at 0, presumably for consistency's sake?
But consistency is illusive here: we count dates, months and years starting
at 1 while hours, minutes and seconds starting at 0. If any, counting
weekdays the same as dates would be more consistent.
Speaking of other languages (real ones): In Chinese the names for Monday to
Saturday are "Weekday one" to "Weekday six". And the names for the months
(1 to 12) has been around for thousands of years. Do we also want to count
January as 0? :-)
Huaiyu