On Mon, Feb 17, 2003 at 04:21:11PM +0100, Peter J. Acklam wrote:
> Since DateTime aims at cleaning up the module mess related to time,
> wouldn't it be a good thing to avoid using Date:: and Time:: modules
> altogether?
> 
> Particularely in this case, I really don't see the need to use an
> external module.  It only requires one line of Perl code to figure out
> whether a given year is a leap year or a common year in the Gregorian
> calendar.  Take your pick:
> 
>   sub isleap {
>       $_[0] % 4 ? 0 : $_[0] % 100 ? 1 : $_[0] % 400 ? 0 : 1;
>   }
> 
>   sub isleap {
>       ($_[0] % 4 == 0 && $_[0] % 100 != 0) || $_[0] % 400 == 0;
>   }
> 
>   sub isleap {
>       (! ($_[0] % 4) && ($_[0] % 100)) || ! ($_[0] % 400);
>   }

Or $foo->is_leap_year (leaving the way open for $obj->is_leap_second one day ;-)

Tim.

Reply via email to