Home > atmlab > time > isleapyear.m

isleapyear

PURPOSE ^

ISLEAPYEAR True for leap years.

SYNOPSIS ^

function t = isleapyear(year)

DESCRIPTION ^

ISLEAPYEAR True for leap years.

   ISLEAPYEAR(YEAR) returns 1's for the elements of YEAR that are leap
   years and 0's for those that are not.  If YEAR is omitted, the current
   year is used.  Gregorian calendar is assumed.

   A year is a leap year if the following returns true

       ( ~rem(year, 4) & rem(year, 100) ) | ~rem(year, 400)

   A year is not a leap year if the following returns true

      rem(year, 4) | ( ~rem(year, 100) & rem(year, 400) )

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

isleapyear.m

SOURCE CODE ^

0001 function t = isleapyear(year)
0002 %ISLEAPYEAR True for leap years.
0003 %
0004 %   ISLEAPYEAR(YEAR) returns 1's for the elements of YEAR that are leap
0005 %   years and 0's for those that are not.  If YEAR is omitted, the current
0006 %   year is used.  Gregorian calendar is assumed.
0007 %
0008 %   A year is a leap year if the following returns true
0009 %
0010 %       ( ~rem(year, 4) & rem(year, 100) ) | ~rem(year, 400)
0011 %
0012 %   A year is not a leap year if the following returns true
0013 %
0014 %      rem(year, 4) | ( ~rem(year, 100) & rem(year, 400) )
0015 
0016 %   Author:      Peter J. Acklam
0017 %   Time-stamp:  2002-03-03 12:51:45 +0100
0018 %   E-mail:      pjacklam@online.no
0019 %   URL:         http://home.online.no/~pjacklam
0020 
0021    error(nargchk(0, 1, nargin));
0022 
0023    if nargin == 0               % If no input argument...
0024       clk = clock;              % ...get current date and time...
0025       year = clk(1);            % ...and extract year.
0026    end
0027 
0028    t = ( ~rem(year, 4) & rem(year, 100) ) | ~rem(year, 400);

Generated on Mon 15-Sep-2014 13:31:28 by m2html © 2005