in reply to Re: Re: Last day of the month. Any shorter
in thread Last day of the month. Any shorter

Still not sure why you'd want to. Just doing the leap-year check by hand is longer than some of the entire solutions presented.

And also:

use Time::Local; sub is_leapyear { 1 == (gmtime(timegm(0,0,1,28,1,$_[0])+24*60*60))[4] }
(But this has severe limitations on the range of valid dates input.)

Replies are listed 'Best First'.
Re: Re: Re: Re: Last day of the month. Any shorter
by greenFox (Vicar) on May 20, 2004 at 05:53 UTC

    I thought you were indicating there was a specific risk in implementing the usual algorithm and I wanted to know what it was.

    The gmtime-timegm method you give is a neat trick but I can't see any good reason to prefer it. It really needs code to catch years outside the epoch range, or at a minimum a comment to highlight it's limitation.

    --
    Do not seek to follow in the footsteps of the wise. Seek what they sought. -Basho