in reply to Broken Date Handling

Because '09' is treated as an octal number (starts with '0'), but the highest digit in base 8 is 7.

JJ

Update:
So the script will fail on the 9th of every month, and on every day in September - a total of 41 days. Or it will work 89% of the time - isn't that good enough :-)

Update 2:
Aha, I didn't notice the $m--

I must admit that on first glance I wouldn't have seen the problem unless it was pointed out that the code was failing. It's the sort of bug that causes lots of swearing at the computer, then a very loud 'Doh!' when you fix it...

Replies are listed 'Best First'.
Re: Re: Broken Date Handling
by davorg (Chancellor) on Oct 10, 2002 at 10:48 UTC

    Yeah. So I fixed it by adding

    $d += 0;

    to the code.

    The script doesn't fail in September. But it fails on both the 8th and the 9th of every month.

    --
    <http://www.dave.org.uk>

    "The first rule of Perl club is you do not talk about Perl club."
    -- Chip Salzenberg

      Why doesn't it fail in September then? Or August, for that matter?

      Of course, you've already done a calculation on that value. Doh.

        Because the $m-- converts $m to a number.

        --
        <http://www.dave.org.uk>

        "The first rule of Perl club is you do not talk about Perl club."
        -- Chip Salzenberg