[Zope] - Some DateTime behaviors I just don't understand

skip@calendar.com (Skip Montanaro) skip@calendar.com (Skip Montanaro)
Thu, 7 Jan 1999 11:31:35 -0500 (EST)


Hmmm...  I received two negative replies to my DateTime constructor
suggestion almost immediately.  Obviously it was not well-received. :-)

My original question asked why the behavior of the DateTime constructor was
so unobvious in the face of apparently simple initial values like 1.  Jim
responded and indicated he was going to (I believe) discard the
interpretation of small numeric initializers as days since 1901-01-01 in the
next release.  I looked at that and thought, "Geez, Jim is probably going to
have to fix a number of places where DateTime(10) means 1901-01-11."  Then I
thought there might be a middle ground, and proposed that.  It's certainly
no worse than the current behavior.  Granted, a little weird, but still,
unambiguous.

I suspect that within the non-Unix world "days since 1901-01-01" is at least
as useful a time measurement as "seconds since 1970-01-01:00:00".  I'm not
much of a database person, but my brief brush with SQL suggests that not
having a way to initialize a DateTime using some sort of "days since
1901-01-01" numeric value is going to be a problem.  Perhaps it can be
tweaked to accept one or more of

    "%d days" % n
    "1901-01-01 + %d" % n

as valid string initializers.

I deal with dates all the time on Musi-Cal, not wide ranges of dates like
database folks do, but human meaningful dates like "all of November", "Sept,
Oct, Nov", "after July 4th", "June thru September" or "any".  Unfortunately,
I still have to discard most of those meaningful, unambiguous dates because
I don't have time to build and continually tweak the mutha of all date
string parsers.  I do handle some other obvious ones like "Christmas" and
"New Year's Eve", though not "Thanksgiving".  Maybe DateTime can evolve into
such a mutha.  Jim, if you'd like some sample input, I have log files full
of dates for you... :-)

While I'm daydreaming, I'd like to see DateTime or some other timestamp
beast be able to represent relative times like "the next two weeks", so that
the absolute value changes depending on when the object is evaluated.  That
would be the cat's pajamas.

Skip Montanaro	   | Mojam: "Uniting the World of Music" http://www.mojam.com/
skip@calendar.com  | Musi-Cal: http://concerts.calendar.com/
518-372-5583