autarch@urth.org via RT wrote:
Show quoted text>> On Tue Jul 07 22:08:38 2009, autarch@urth.org wrote:
>>> The problem being that there's nothing to search until it's generated.
>> Are you saying it regenerates the database at run time every time? How
>> about doing it once when DateTime::TimeZone is installed?
>
> Storing the changes in memory uses up a fair bit of memory.
>
> Generating 1000+ years worth would make loading each time zone take much
> much more memory. It does it at runtime to optimize for the common case of
> not needing to look too far in the future.
Generating 1000+ years of what? The Olsen database doesn't go forward that
far. And who says it has to all be in memory? There's any number of
techniques to leave things on disk.
The C code figured this out 20 years ago!
Show quoted text>>> Just use UTC.
>> What the hell kind of answer is that?! I'll take "yeah, that sucks but
>> I don't have the tuits to optimize it. Here's some thoughts on how to
>> do it..." but not "use UTC". Come on. While time zones are annoying,
>> you can't just blow them off! Especially as the maintainer of the most
>> heavily used date module in Perl!
>
> It's the right answer. Using _Olson_ time zones with far future dates just
> doesn't make any sense. These time zones exist for the purpose of dealing
> with the dictates of modern political entities.
>
>> While I agree worrying about the niggling details of historical time
>> zone changes 1000 years from now is silly, THE SUN WILL STILL BE IN THE
>> SKY and that's what a time zone offset basically reflects. And while
>
> Yes, that's what the _offset_ reflects. However, the DST changes reflect
> the random whims of idiot politicians.
You're absolutely correct, it sucks and its broken. However, you maintain a
date/time library which deals with time zones. You have to deal with the
reality. Full stop.
Show quoted text> If you just want an offset, use a static offset like '-0500'. That will be
> fast, since there's no DST rules to deal with.
I, in fact, don't want an offset at all. I just want a DateTime object
representing the date I gave it. Why is it calculating the offset just to
instantiate? Can't it wait until I ask for it?
Show quoted text>> Another simple optimization would be to cache what the latest Olsen
>> entry is and then just not bother looking beyond that.
>
> That doesn't make any sense. The last Olson entry is purely arbitrary
> based on how many years of pre-calculation the module ships with, and when
> I happen to generate it.
>
> Or do you mean the offset without DST? Then someone else will complain
> that it's broken at some arbitrary date (like 11 years out).
Ok, maybe I'm missing something here. If I hand you something like "July 9th,
2009 America/Chicago" and ask what the offset is taking into account DST you
look at the last DST rule before that date and apply it. Let's say the last
rule change was 2007 (which I think it was) so you look at that and apply it
and that's that, right?
Why would the algorithm be any different for 3009? What's all this extra
calculation you're talking about? Are you generating rules for every year up
to 3009 or something? Wouldn't that just be repeating the same calculation
over and over?
Show quoted text> For people who need to calculate far future dates, there are other
> solutions (UTC or some other fixed offset) that work. But either way, you
> as the user need to make a decision about what you want. I can't make that
> decision for you, I just provide the options.
>
> If you want to take a stab at optimizing the changes generation, that's
> fine with me, but personally I don't think it's wortwhile, since there's
> no sane use case for Olson time zones in the far future.
Look, all I know is every other datetime library that goes past 2038 doesn't
take 10 seconds to make this calculation. Something is wrong here.
Show quoted text>> Somewhat apropos, for dates far in the past, before time zones, I've
>> seen 64 bit Linuxen use the lat/long for the city in question which is
>> pretty clever.
>
> A DT::TZ::LatLong would be very cool.
>
> Actually, the Olson database approximates this, since pre-modern times it
> uses local mean time, which is an offset based off the lat/long of the
> named city.
That sounds like it.
--
The past has a vote, but not a veto.
-- Mordecai M. Kaplan