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

[MacPerl] Bug in localtime?



Hi,

I'm not sure if this is old news or if I'm doing something wrong, but 
I seem to have found a bug in localtime (and judging from the list 
archives, it's not the first).

I'm writing a routine that has to translate date/times from local 
time into GMT time.  And since Sunday is the first day of Daylight 
Savings Time, I was testing to ensure that the routine could handle 
that correctly.

I ran the following code on my Sun Solaris box as well as MacPerl v5.2.0r4.

     #!/usr/local/bin/perl

     $time = time;
     for ($i = 0; $i < 6; $i++) {
        $isdst = (localtime($time))[8];
        print scalar(localtime($time)), "  $isdst\n";
        $time += 24*60*60;  #advance one day (24 hours)
     }


MacPerl said:
Thu Mar 30 15:45:11 2000  0
Fri Mar 31 15:45:11 2000  0
Sat Apr  1 15:45:11 2000  0
Sun Apr  2 15:45:11 2000  0
Mon Apr  3 15:45:11 2000  0
Tue Apr  4 15:45:11 2000  0


The Sun box said:
Thu Mar 30 15:46:35 2000  0
Fri Mar 31 15:46:35 2000  0
Sat Apr  1 15:46:35 2000  0
Sun Apr  2 16:46:35 2000  1
Mon Apr  3 16:46:35 2000  1
Tue Apr  4 16:46:35 2000  1


I'm inclined to believe the Sun box.  Shouldn't 'isdst' be true on 
dates that Daylight Savings Time is in effect?  And shouldn't the 
reported time change by an hour when DST turns on?

I've got my Date & Time Control Panel configured for 'Set 
Daylight-Saving Time Automatically', with the 'City in the current 
time zone' as 'Detroit'.


Am I doing anything wrong?  Will this be fixed in the upcoming release?

Thanks,
--Michael
-- 

Michael Leahy             Systems Analyst, Academic Computing
leahym@river.it.gvsu.edu  CourseInfo Systems Administrator
616-895-3095              207 Manitou Hall
616-895-3889 fax          Grand Valley State University
                           Allendale, Michigan  49401-9403

   The ultimate measure of a man is not where he stands in
   moments of comfort and convenience but where he stands at
   times of challenge and controversy. --Martin Luther King Jr.

# ===== Want to unsubscribe from this list?
# ===== Send mail with body "unsubscribe" to macperl-request@macperl.org