[Python-Dev] dateutil

Tim Peters tim.one at comcast.net
Thu Mar 11 16:24:46 EST 2004


[Brett C.]
> Before I give my vote on DateUtil I know I would love to hear Gustavo
> give a quick comparison to datetime in terms of what DateUtil provides
> over datetime.  For instance, as Tim showed above (I should have known
> there was a better way with datetime than with my nutty way of doing
> it), datetime supports time deltas.  So why should we use DateUtil's
> or what should we try to take from it?  Same for parser (compared to
> strptime) and tz (compared to tzinfo).  I could obviously stare at the
> wiki and datetime docs, but I am sure Gustavo can give a better
> overview than I could glean on my own.

WRT time deltas, datetime stuck to things people can't reasonably argue
about, while DateUtil (like mxDateTime before it) is in the business of
guessing what people really want.  That's why, e.g., datetime.timedelta has
no months= argument.  People can (and do) argue about what "a month" means
(what's one month after January 31?  A few days into March?  The last day of
February?  4 weeks later?  30.436875 days later (that's 365.2425/12 == the
average length of a year in days divided by 12)?).  They can't argue about
what "a week" means -- it's 7 days.  And a day is 24 hours, and an hour is
60 minutes, and a minute is 60 seconds, and a second is 10000000
microseconds, and "leap seconds" don't exist.

Ya, that was a gutless decision, but it also means datetime isn't about to
change the rules on you because some other notion of "month" becomes
fashionable.  datetime is about naive time, an idealized calendar and an
idealized clock that won't change even if social or legislative or physical
reality does.  It's a safe fantasy land where you can block out the world's
noise.  That's also why it ignores timezones <wink>.

> The rrule idea does sound cool and could be neat to add to datetime.
> I can see having an iterator for these things being useful to someone
> (unless I am making myself partially look like a fool again by having
> this be in datetime already without me realizing it).

Nope, they're not, and things like "the second Tuesday of the month" aren't
supported natively by datetime at all.  They're easy enough to compute using
datetime as a basis, but the datetime Wiki was full of incompatible
suggestions about what people really wanted there.  We didn't have time (or
interest) in settling those arguments, so we covered our asses by leaving it
out.  Gustavo is covering his by appealing to an external standard, which is
an admirable strategy.




More information about the Python-Dev mailing list