mxDateTime history (Re: mktime, how to handle dates before 01-01-1970 ?)
Tim Chase
python.list at tim.thechases.com
Fri Oct 9 08:39:43 EDT 2009
> Month arithmetic is a bit of a mess, since it's not clear how
> to map e.g. Jan 31 + one month.
"Jan 31 + one month" usually means "add one to the month value
and then keep backing off the day if you get an exception making
the date", so you'd get Feb 31, exception, Feb 30, exception, Feb
29, possibly an exception, and possibly/finally Feb 28th. This
makes pretty intuitive sense to most folks and is usually what's
meant.
I've found that issues and confusion stem more from the
non-commutative reality that "Jan 31 + (1 month) + (-1 month) !=
Jan 31 + (-1 month) + (1 month)" or the non-associative "Jan 31 +
(1 month + 1 month) != (Jan 31 + 1 month) + 1 month" :-/
So yes, messy it is!
-tkc
More information about the Python-list
mailing list