Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!samsung!emory!wrdis01!nstn.ns.ca!daniel From: daniel@nstn.ns.ca (Daniel MacKay) Newsgroups: comp.lang.perl Subject: "localtime(time)" $mon wrong?? Message-ID: <1991Apr16.163755.9636@nstn.ns.ca> Date: 16 Apr 91 16:37:55 GMT Organization: NSTN Network Operations Centre, Nova Scotia, Canada Lines: 27 Hello! A tiny program that has been crunching dates for the last couple of months just recently stopped working- on the 31st of March, "localtime" started returning dates for the 1st of March; but as-of the real 1st of April, it's returning dates as the corresponding day in March! Below is a program that shows localtime in action. It's SunOS 4.1, Perl 4.0 PL3, running on a Sparcstation 1+. Does anyone have any suggestions? ADthanksVANCE! -dan ---------------------------------------------------------------------- #!/bin/perl require 'timelocal.pl' || die "can't find the library!\n"; $isdst = 1; print "It's ", &formattime(time), " now!\n"; sub formattime{ local ($gmtime,$sec,$min,$hours,$mday,$mon,$year,$wday,$yday) = @_ ; ($sec,$min,$hours,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($gmtime); sprintf("%02d/%02d/%02d-%02d:%02d:%02d", $mday,$mon,$year,$hours,$min,$sec); }; ----------------------------------------------------------------------