that's odd. I developed and tested this on OSX, i think..
maybe it was the FreeBSD box.

The TZ variable will go look under /usr/share/zoneinfo for a
file of that name. man 3 tzset for details.

Elegant it ain't.. In fact, there is a much nicer way via
C and the localtime libc function (at least in FreeBSD) where
localtime returns a tm struct with the final member
'gmtoff', GMT offset in seconds, but for some reason perl refuses to expose this
in localtime or POSIX::localtime. Probably due to cross platform
variation.

- Mark.


On Sunday, December 8, 2002, at 10:59 pm, Tamsin wrote:

use Time::Local;
$ENV{TZ}="Australia/Sydney";

my @gmt=gmttime;
my $tzdiff = timegm(@gmt)-timelocal(@gmt);

is the kludgey way to do it, $tzdiff is in seconds.
gmttime was a deliberate error?

I was hoping for something a little more ... elegant.

But it works, (yay! thanks!).

Well to clarify it works under BSD, The mac thinks that Sydney uses GMT, I'm getting the impression that OSX doesn't use the same time environment variables or doesn't handle its timezone files in the same way but I'm not going to spend time trying to fix this...

T.
--
The future's bright, the future's orange!

http://www.tamsin.com



Reply via email to