It it now a leap year?

Simon Andrews simon.andrews at bbsrc.ac.uk
Thu Aug 9 15:52:46 UTC 2007


Mike - EMAIL IGNORED wrote:
> Is there a system call or variable that will
> tell me if it is now a leap year, or should I
> do the arithmetic?

Probably lots of ways in lots of languages, but just for kicks (should 
be all on one line):

perl -MDate::Calc -e  "print 
Date::Calc::leap_year((localtime())[5]+1900)?'Leap year':'Not leap year'"

This uses the Date::Calc module in Perl which does loads of nice date 
calculations and manipulations.  You can install this with

yum install perl-Date-Calc

and then 'man Date::Calc' to see the documentation.

Simon.




More information about the users mailing list