[tpm] TZ code to hour offset conversion ideas?

Liam R E Quin liam at holoweb.net
Wed Oct 8 18:40:12 PDT 2008


On Wed, 2008-10-08 at 19:28 -0400, Madison Kelly wrote:
> Hi all,
> 
>    I want to create a simple ... "library"? ... to provide data for a 
> simple method do say:
> 
> my $offset=&get_tz_offset("est", "1998-06-15");
> 
>    I've got the TZ data from: http://www.twinsun.com/tz/tz-link.htm

Most (not all) operating systems have this too.  And there's probably
a Perl module to access it.

Note that your example is dangerous -- EST will always be "eastern
standard time" and EDT will always be eastern daylight [savings] time;
people switch from using EDT to using EST for the Winter.

So you need three pieces of information -- the date of the changes in a
given year (and this is in general political, and does not universally
follow any algorithm, although most of the time in most countries it
appears to in practice), the date and the base location or timezone.

Date::Manip can probably do what you want, though, via Date_ConvTZ.

If not, try Date::ParseDate and/or Time::Zone instead.
E.g. use Time::Zone; print tz_offset("CET");

Liam

-- 
Liam Quin - XML Activity Lead, W3C, http://www.w3.org/People/Quin/
Pictures from old books: http://fromoldbooks.org/
Ankh: irc.sorcery.net irc.gnome.org www.advogato.org



More information about the toronto-pm mailing list