Home > atmlab > time > easterday.m

easterday

PURPOSE ^

EASTERDAY Easter day for a given year.

SYNOPSIS ^

function [month, day] = easterday(year)

DESCRIPTION ^

EASTERDAY Easter day for a given year.

   [MONTH, DAY] = EASTERDAY(YEAR) returns the month and day for easter day.

   If no year is specified, the current year is used.  Gregorian calendar
   is assumed.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

easterday.m

SOURCE CODE ^

0001 function [month, day] = easterday(year)
0002 %EASTERDAY Easter day for a given year.
0003 %
0004 %   [MONTH, DAY] = EASTERDAY(YEAR) returns the month and day for easter day.
0005 %
0006 %   If no year is specified, the current year is used.  Gregorian calendar
0007 %   is assumed.
0008 
0009 %   Author:      Peter J. Acklam
0010 %   Time-stamp:  2002-05-24 15:26:50 +0200
0011 %   E-mail:      pjacklam@online.no
0012 %   URL:         http://home.online.no/~pjacklam
0013 
0014    nargsin = nargin;
0015    error(nargchk(0, 1, nargsin));
0016    if ~nargsin
0017       clk = clock;
0018       year = clk(1);
0019    end
0020 
0021    % The following algorithm is from the Calendar FAQ,
0022    % http://www.tondering.dk/claus/calendar.html.
0023 
0024    G = rem(year, 19);
0025 
0026    % For the Julian calendar:
0027    % I = rem(19*G + 15), 30);
0028    % J = rem(year + year/4 + I), 7);
0029 
0030    % For the Gregorian calendar:
0031    C = fix(year/100);
0032    H = rem((C - fix(C/4) - fix((8*C + 13)/25) + 19*G + 15), 30);
0033    I = H - fix(H/28)*(1 - fix(H/28)*fix(29/(H + 1))*fix((21 - G)/11));
0034    J = rem((year + fix(year/4) + I + 2 - C + fix(C/4)), 7);
0035 
0036    L = I - J;
0037    month = 3 + fix((L + 40)/44);
0038    day = L + 28 - 31*fix(month/4);

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