time Module Inconsistencies

Martin Miller mmiller at tx3_DELTHIS_.com
Wed Feb 19 20:07:00 EST 2003


In the standard Python time module, the item at index 6 of the "time 
tuple" which is returned from gmtime() and localtime() is defined to be 
an integer in the range [0,6] where Monday is 0.

However, the "%w" format directive to strftime(), when given the same 
sort of tuple, returns a weekday number decimal string where Sunday 
equals 0.

This unnecessarily complicates certain common sorts of date 
manipulations, IMHO (and probably also does the same to some degree to 
the internals of the time module's routines, I imagine).

Does anywone know why this came to be this way? It probably can't be 
changed at this point in time without breaking too much existing code, 
but I'm curious if there's a logical explanation.

TIA,
Martin





More information about the Python-list mailing list