[comp.lang.perl] "localtime

daniel@nstn.ns.ca (Daniel MacKay) (04/16/91)

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);
   };
----------------------------------------------------------------------