bsb has asked for the wisdom of the Perl Monks concerning the following question:
Is there a way to get a time zone from Windows? From strftime I got something semi-useful:DateTime->from_epoch(epoch => $t, time_zone => 'local');
I decided to calculate the difference between localtime and gmtime for now. Is there a better alternative?C:\>perl -MPOSIX=strftime -le "print strftime(q(%Z), localtime)" AUS Central Standard Time
Thanks, Brad#!/usr/bin/perl -w use strict; use DateTime::Duration; my ($lh, $lm) = (localtime)[2,1]; my ($gh, $gm) = (gmtime)[2,1]; my $dur = DateTime::Duration->new( hours => ($lh-$gh), minutes => ($lm +-$gm)); print sprintf "%+02.2d%02d\n", $dur->in_units('hours','minutes');
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Determining Time Zone on Win32
by ashokpj (Hermit) on May 10, 2006 at 06:47 UTC | |
by bsb (Priest) on May 10, 2006 at 07:01 UTC |