Tugger the SLUGger!SLUG Mailing List Archives

Re: [SLUG] Best API/abstraction?

Jeff Waugh <jdub@xxxxxxxxxxxxxx> writes:
> <quote who="Jamie Wilkinson">
>> I for one am glad such pages exist.  I wish the inventors of time_t had
>> read it.
> So which language / library has a great abstraction for time and date stuff,
> helping you deal with the intricacies of this craziness?

None of them.  Even the good languages have nasty side-bits like a "don't be
broken" switch, and even a perfect language would still have the pain of
dealing with political, not technical, issues like timezone-associated dates.

Oh, and the fact that date math is *not* simple, since you can't convert
between various durations; a question such as "how many seconds in a week" can
only be answered "it varies..."

FWIW, the link I posted earlier was about time handling in Common Lisp, which
gets this less wrong than most platforms ... but that document was written
because the standard was imperfect.

Perl, meanwhile, has good support in various non-core library modules, but
many of those have things like a "$Class::Date::DST_ADJUST" value to determine
which behaviour you want for math involving DST and/or leap-seconds.

As an example of a well-documented set of complications and how they are
handled, the DateTime module does well:


After you read through the 250 lines of warnings, complications, caveats, and
examples of how you can have two completely correct, valid, sensible results
that are absolutely in contradiction with each other...


Time.  Boy, does it suck. :)

✣ Daniel Pittman            ✉ daniel@xxxxxxxxxxxx            ☎ +61 401 155 707
               ♽ made with 100 percent post-consumer electrons