in reply to date and time

Looks like you have been into the Perl Cookbook in chapter 3 and that you have been looking at page 71. The edition I have erroneously states that the range for $yday is 1-366 (but it's really 1-365). I think that the range for $sec is also wrong (0-60 vs 0-59).

Pay special attention to the $isdst variable. It's going to come in handy on October 28 when we "fall back".

$isdst is important if your machine is set to Universal Time and you are processing epoch seconds that are expressed in a US time zone (Eastern for example). If you are doing date math on a UT box but using EST or EDT, you need to examine $isdst to know how many seconds to subtract.

I have been bitten by this, but that's because I'm dumb.

Replies are listed 'Best First'.
Re: Re: date and time
by belden (Friar) on Oct 16, 2001 at 08:33 UTC
    Hi Stegalex
    The edition I have erroneously states that the range for $yday is 1-366 (but it's really 1-365)

    My book shows $yday as having a range from 0-365, which gives $yday an effective max of 366. This makes sense; there are 366 days in a leap year, so the range of $yday has to be effectively 366.

    I think that the range for $sec is also wrong (0-60 vs 0-59)

    Just as we can have leap days, we can have leap seconds- though they generally get less press. ("What? You were born on a leap second? That means you have a birthday, what... every time some standards organization wants you to have one?!"). Or, couched in the slightly less facetious tones of Cookbook: The values for second range from 0-60 to account for leap seconds, you never know when a spare second will leap into existence at the urging of various standards bodies.

    blyman