mxDateTime history (Re: mktime, how to handle dates before 01-01-1970 ?)

Rhodri James rhodri at wildebst.demon.co.uk
Sun Oct 11 08:33:29 EDT 2009


On Fri, 09 Oct 2009 13:39:43 +0100, Tim Chase  
<python.list at tim.thechases.com> wrote:

>> 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" :-/

I'd hazard a guess that what we're actually seeing is people mentally
rebasing their indices, i.e. counting from the end of the month rather
than the start, which makes "the last day of January" and "January 31"
not the same thing really.  Unfortunately we're very fuzzy about when
we do things like this, which makes it hard on a poor programmer.

-- 
Rhodri James *-* Wildebeest Herder to the Masses



More information about the Python-list mailing list