APM: GMT question
Mike Stok
mike at stok.co.uk
Wed Dec 4 13:50:16 CST 2002
On Wed, 4 Dec 2002, Goldilox wrote:
> If I'm doing this:
> $timezoneoffset = -6;
> $offset = $timezoneoffset * 3600;
> ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = gmtime(time +
> $offset);
>
> I am wondering if Windows vs Unix if any OS will account for DST (Daylight
> Savings Time)? My assumption is Windows will and Unix won't, but maybe there is
> a workaround for Unix (or maybe I'm wrong in my assumptions).
GMT (or UTC) doesn't have daylight savings, but localtime will tell you if
the time in the local timezone uses DST or not.
Perl does deal with timezones and DST, try this and look at the output -
gmtime never has daylight savings:
use POSIX qw/ tzset /;
use Time::Local;
use constant TORONTO => 'EST5EDT'; # -15C yesterday morning
use constant AUSTIN => 'CST6CDT'; # considerably warmer...
my $now = time;
my $then = timelocal(0, 0, 12, 1, 6, 2001); # July
foreach my $time ($now, $then) {
foreach my $timeZone (AUSTIN, TORONTO) {
$ENV{'TZ'} = $timeZone;
tzset;
print "$time: $time, time zone $ENV{'TZ'}\n";
print " gmtime: @{[scalar(gmtime $time)]} @{[gmtime $time]}\n";
print " localtime: @{[scalar(localtime $time)]} @{[localtime $time]}\n";
print "\n";
}
}
Hope this helps,
Mike
--
mike at stok.co.uk | The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/ | GPG PGP Key 1024D/059913DA
mike at exegenix.com | Fingerprint 0570 71CD 6790 7C28 3D60
http://www.exegenix.com/ | 75D2 9EC4 C1C0 0599 13DA
More information about the Austin
mailing list