[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Q on Mac Time Zones



At 15.51 +0100 1999-01-08, Christopher F. Blanford wrote:
>This won't work in Europe and Asia where localtime>gmtime?
>
>Anywhere east of Greenwich will return a negative value rather than a
>positive one.

What about:

#!perl
use Time::Local;

sub timezone () {
     my $diff = (timelocal(localtime) - timelocal(gmtime)) / 36;
     my $sgn = $diff > 0 ? '+' : '-';
     $diff =~ s/^-?(\d{3})$/${sgn}0$1/;  # add leading zero if only three
digits
     $diff;
}

print timezone;

__END__

/Cajo.

___Carl_Johan_Berglund_________________________
   Adverb Information
   carl.johan.berglund@adverb.se
   http://www.adverb.se/



***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch