CFLib.org – Common Function Library Project

GetEaster([TheYear])

Last updated September 4, 2001

author

Ken McCafferty

Version: 1 | Requires: CF5 | Library: DateLib

Description:
Returns the date for Easter in a given year. If no year is specified, defaults to the current year.

Return Values:
Returns a date object.

Example:

<CFOUTPUT>
Easter falls on #DateFormat(GetEaster(), 'dddd mmmm dd, yyyy')# this year.
</CFOUTPUT>

Parameters:

Name Description Required
TheYear The year to get Easter for. No

Full UDF Source:

/**
 * Returns the date for Easter in a given year.
 * Minor edits by Rob Brooks-Bilson (rbils@amkor.com).
 * 
 * @param TheYear 	 The year to get Easter for. 
 * @return Returns a date object. 
 * @author Ken McCafferty (mccjdk@yahoo.com) 
 * @version 1, September 4, 2001 
 */
function GetEaster() {
  Var TheYear=iif(arraylen(arguments) gt 0,"arguments[1]", "Year(Now())");       
  Var century = Int(TheYear/100);
  Var G = TheYear MOD 19;
  Var K = Int((century - 17)/25);
  Var I = (century - Int(century/4) - Int((century - K)/3) + 19*G + 15) MOD 30;
  Var H = I - Int((I/28))*(1 - Int((I/28))*Int((29/(I + 1)))*Int(((21 - G)/11)));
  Var J = (TheYear + Int(TheYear/4) + H + 2 - century + Int(century/4)) MOD 7;
  Var L = H - J;
  Var EasterMonth = 3 + Int((L + 40)/44);
  Var EasterDay = L + 28 - 31*Int((EasterMonth/4));
  return CreateDate(TheYear,EasterMonth,EasterDay);
}
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Kevin Cotton added
date2ExcelDate
May 5, 2016

Raymond Camden added
CapFirst
April 25, 2016

Chris Wigginton added
loremIpsum
January 18, 2016

Gary Stanton added
calculateArrival...
November 19, 2015

Sebastiaan Naafs - van Dijk added
getDaysInQuarter
November 13, 2015

Created by Raymond Camden / Design by Justin Johnson