[MacPerl-Porters] MacPerl daylight saving time issue
[email protected] (Thomas Wegner) Fri, 13 Sep 2002 18:53:10 +0200
| Newsgroups | perl.macperl.porters |
|---|---|
| Message-ID | <p04320401b9a760b85014@[149.225.12.22]> |
Hi, to make a long story short: In the past, I have sent some Mac OS patches to Steffen Beyer for his Date::Calc module. He just released Date::Calc 5.1, which is basically version 5.0 plus Mac OS Classic support. While running the module tests for a pre-release version, I noticed 3 failures, all related to the daylight saving time flag. $dst is 0 for winter time, and 1 for summer time (and -1 if not supported). Said tests check if $dst == 0 for a given date and fail. My Mac is currently set to summer time, hence I first thought that $dst is correctly set to 1. But Steffen reminded me, that on Unix, Windows etc. the daylight saving time flag is set according to the given date. For instance, on December 24th, 2001, $dst should be 0 (see the sample script below), right? But obviously, if a Mac is set to summer time, and I check the Christmas Eve date, $dst will be 1 (!). My conclusion: $dst depends on the Date&Time control panel setting, and not on a given date. I won't say this is a bug, but it is, isn't it? :-) I am confused, to be honest. Is this a known issue (in GUSI, I think), or a bug in my brain? Ideas? #!perl -w use Time::Local; $time = timelocal(0, 0, 12, 24, 11, 2001); # Dec 24th, 2001 12:00:00 ($sec,$min,$hour,$day,$month,$year,$dow,$doy, $dst) = localtime( $time ); $year += 1900; $month += 1; print "year= $year\n"; print "month = $month\n"; print "day = $day\n"; print "hour = $hour\n"; print "min = $min\n"; print "sec = $sec\n"; print "doy = $doy\n"; print "dow = $dow\n"; print "dst = $dst\n"; __END__ Result: year= 2001 month = 12 day = 24 hour = 12 min = 0 sec = 0 doy = 357 dow = 1 dst = 1 # daylight saving time, should be 0 on Dec 24th, 2001 ??? Regards, Thomas.