I'm working on a world clock web application, and I'd like to add a function to note how and when each location will next undergo a DST change.
I'm using the DateTime
and DateTime::Timezone
CPAN modules, which seem to provide every conceivable function apart from this one! DateTime::Timezone
is an implementation of the tz/Olson database.
So far, I'm comparing local offset to UTC, both now and 24 hours ahead, which allows me to flag what the effect is but not exactly when it occurs.
My proof of concept calculates this every minute. I'm thinking the next step is either:
create a lookup table using a similar method for the next 365 days to identify affected days, then look at each hour within those days
somehow parse the DST rules in the
DateTime::Timezone
module.
Any ideas? I should note that my knowledge of Perl is pretty basic.
Edit:
Looks like another option might be to port to PHP and use DateTimeZone::getTransitions
. This did return an array of all transitions, but PHP 5.3.0 just added optional timestamp_begin
and timestamp_end
paramaters to limit to a range.