At 8:26 -0500 11/21/2001, Chris Nandor wrote: >At 14:19 +0100 2001.11.21, Louis Pouzin wrote: >>The Mac Date & Time control panel keeps the time zone. e.g. Paris. >> >>Is there a way to grab this info, in MacPerl, or at least the difference from >>UTC ? > > use Time::Local; > $diff = (timelocal(localtime) - timelocal(gmtime)) / 36; > $diff = sprintf "%+0.4d", $diff; # add sign, leading zero(es) > print $diff;
Code assumes "well-behaved" time zones. Not all areas have local time which is some multiple of 3600 seconds away from UTC (I don't off hand know of any areas which aren't some multiple of 900 seconds from UTC). How important this quibble is depends on the situation in which the code is used. --John