Why does time.gmtime() use Monday=0?

Tim Bell bhat at cs.mu.OZ.AU
Wed Jun 14 22:46:55 EDT 2000


Hi,

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 - bhat at cs.mu.oz.au - Dept of Comp Sci & SE - Uni of Melbourne, Aust.




More information about the Python-list mailing list