Looking at the difference between localtime() and gmtime() will tell me the offset between local time and GMT, but it won't tell me what time zone I am in. For example, in the summer in Phoenix the offset is the same as the offset in L.A., but in the winter the Phoenix offset is the same as the Denver offset. So if the offset is seven hours, how do I know if I am in Denver, Phoenix or L.A?
The Time::Timezone CPAN module looks like a good start, but I doubt that it is portable to all Unices. Here's a comment from the source code:
# Hack to deal with 'PST8PDT' format of TZ
# Note that this can't deal with all the esoteric forms, but it
# does recognize the most common: [:]STDoff[DST[off][,rule]]
Does anyone know a 100% portable method for getting the name of the locat time zone??
Richard Anderson, Ph.D. www.unixscripts.com
Perl / Java / Oracle / Unix Richard.Anderson at raycosoft.com
Raycosoft, LLC Seattle, WA, USA
----- Original Message -----
From: "Darren/Torin/Who Ever..." <torin at daft.com>
To: "starfire" <starfire at zipcon.net>
Cc: <spug-list at pm.org>
Sent: Monday, March 19, 2001 10:28 PM
Subject: Re: SPUG: Portable way to get local time zone
> Richard Anderson, in an immanent manifestation of deity, wrote:
> >What is a portable way to get the local timezone from within a mod_perl
> >module? I see that on Linux 2.2.16 I can do "ls -l /etc/localtime" and on
> >Solaris 2.7 I can do "tail -1 /etc/TIMEZONE", but I want something that is
> >portable.
> >
> >The $TZ variable does not seem to be set in my mod_perl program's
> >environment ...
>> You can look at the difference between localtime() and gmtime(). I did
> this at first.
>> But then I needed to do more and found out that there is a
> Time::Timezone modules on CPAN...
>> Darren
> --
> <torin at daft.com><http://www.daft.com/~torin/> <torin at debian.org><perl at slut.org>
> Darren Stalder/2608 Second Ave, @282/Seattle, WA 98121-1212/USA/+1-206-ELF-LIPZ
> @ Make a little hot-tub in your soul. @
>> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
> POST TO: spug-list at pm.org PROBLEMS: owner-spug-list at pm.org> Subscriptions; Email to majordomo at pm.org: ACTION LIST EMAIL
> Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
> For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest
> Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/>>>
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
POST TO: spug-list at pm.org PROBLEMS: owner-spug-list at pm.org
Subscriptions; Email to majordomo at pm.org: ACTION LIST EMAIL
Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest
Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/