EasterSunday
Back to ListDescription: Calculate the date of the Easter sunday for a given year.
FileMaker Prototype:
Set Variable [$res; ACF_Run("EasterSunday"; int_inputYear)]
Category: UTILITY
Function source:
function EasterSunday (int inputYear)
int a = mod(inputYear , 19);
int b = (inputYear / 100);
int c = mod(inputYear , 100);
int d = (b / 4);
int ee = mod(b , 4);
int f = ((b + 8) / 25);
int g = ((b - f + 1) / 3);
int h = mod((19 * a + b - d - g + 15) , 30);
int i = (c / 4);
int k = mod(c , 4);
int l = mod((32 + 2 * ee + 2 * i - h - k), 7);
int m = ((a + 11 * h + 22 * l) / 451);
int n = ((h + l - 7 * m + 114) / 31);
int p = mod(h + l - 7 * m + 114 , 31) + 1;
date DateEasterSunday = date( format("%04d-%02d-%02d", inputYear, n, p),"%Y-%m-%d");
return string(DateEasterSunday);
end
The EasterSunday function calculates the date of Easter Sunday for a given year, which can be helpful when calculating other movable holidays.
The algorithm is directly implemented from this Wikipedia article on Easter formulas.
Example
Set Variable [$res; ACF_Run("EasterSunday"; 2024)]
The result is March 31, 2024.
Differences from the JavaScript function on Wikipedia
The JavaScript version uses Math.floor to convert floats to integers by ignoring decimals. In ACF, variables are declared as int, so assigning a float to an int results in an implicit floor function, making floor unnecessary. If you wish to use floor on a float and assign it to another float, you can use the int function for conversion.
Additionally, the JavaScript version uses the variable e in one calculation. However, e is a constant in ACF (2.718281828459), representing the base of natural logarithms. To avoid conflicts, we renamed it to ee in the ACF function.
Otherwise, the functions remain quite similar in structure.
