[lug] Perl days/dates

Atkinson, Chip CAtkinson at Circadence.com
Wed Nov 15 10:07:27 MST 2000


Thanks a ton!  That was certainly it.  The bad thing too is that it was in
the book in front of me, I just over looked it.  To quote:
"If you're passing month and year values to timeloal, it expects values with
the same range as those which localtime returns.  Namely, months start at 0,
and years have 1900 subtracted from them."

(O'Reilly's Perl Cookbook, p. 75, recipe 3.2)

I hate it when that happens.  Thanks to all.

Chip

> -----Original Message-----
> From: Pete Krawczyk [mailto:pak at unixdba.com]
> Sent: Wednesday, November 15, 2000 9:28 AM
> To: lug at lug.boulder.co.us
> Subject: Re: [lug] Perl days/dates
> 
> 
> Atkinson, Chip wrote:
> 
> > $year = 2000;
>    $year -= 1900;
> 
> > $mon  = 11;
> > $mday  = 4;
> > for ($mday = 1; $mday < 11; $mday++)
> > {
> >   $TIME = timelocal (1, 1, 1, $mday, $mon, $year);
> >    print ("\nYear: $year, Month: $mon, Day: $mday");
> > 
> >    @datestuff = localtime ($TIME);
> >    print (" Mon: $datestuff[4]");
> >    print (" Year: ", $datestuff[5] + 1900);
> >    print (" Wday: ", $days[$datestuff[6]], "\n");
> > }
> 
> You're currently asking for the year 3900.
> timelocal() shouldn't be allowing the year that high.
> 
> Hope this helps,
> -Pete K
> -- 
> Pete Krawczyk
>    UNIX/RDBMS Administrator
>    Absolute Performance
>    pak at unixdba.com
> 
> 
> _______________________________________________
> Web Page:  http://lug.boulder.co.us
> Mailing List: http://lists.lug.boulder.co.us/mailman/listinfo/lug
> 




More information about the LUG mailing list