note 14805 modified in function.easter-days by danbrown

From: Date: Sun, 20 Jul 2008 01:58:39 +0000
Subject: note 14805 modified in function.easter-days by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-141929@lists.php.net to get a copy of this message
This function appears to be Britanno-centric. When attempting to calculate the Gregorian date for Easter for years prior to 1753, the function returns the number or days since March 21st in the Julian Calendar, even though the Gregorian system was in effect in the rest of Europe since 1582. If you wish to calculate the date of easter for a Gregorian date from 1582 onward, use the following function, which duplicates the funcionality of easter_days: <?php function easter_days2($year) { #First calculate the date of easter using Delambre's algorithm. $a = $year % 19; $b = floor($year / 100); $c = $year % 100; $d = floor($b / 4); $e = $b % 4; $f = floor(($b + 8) / 25); $g = floor(($b - $f + 1) / 3); $h = (19 * $a + $b - $d - $g + 15) % 30; $i = floor($c / 4); $k = $c % 4; $l = (32 + 2 * $e + 2 * $i - $h - $k) % 7; $m = floor(($a + 11 * $h + 22 * $l) / 451); $n = ($h + $l - 7 * $m + 114); $month = floor($n / 31); $day = $n % 31 + 1; #Return the difference between the JulianDayCount for easter and March 21'st #of the same year, in order to duplicate the functionality of the easter_days function return GregorianToJD($month, $day, $year) - GregorianToJD(3,21,$year); } ?> --was-- This function appears to be Britanno-centric. When attempting to calculate the Gregorian date for Easter for years prior to 1753, the function returns the number or days since March 21st in the Julian Calendar, even though the Gregorian system was in effect in the rest of Europe since 1582. If you wish to calculate the date of easter for a Gregorian date from 1582 onward, use the following function, which duplicates the funcionality of easter_days: <?php function easter_days2($year) { #First calculate the date of easter using Delambre's algorithm. $a = $year % 19; $b = floor($year / 100); $c = $year % 100; $d = floor($b / 4); $e = $b % 4; $f = floor(($b + 8) / 25); $g = floor(($b - $f + 1) / 3); $h = (19 * $a + $b - $d - $g + 15) % 30; $i = floor($c / 4); $k = $c % 4; $l = (32 + 2 * $e + 2 * $i - $h - $k) % 7; $m = floor(($a + 11 * $h + 22 * $l) / 451); $n = ($h + $l - 7 * $m + 114); $month = floor($n / 31); $day = $n % 31 + 1; #Return the difference between the JulianDayCount for easter and March 21'st #of the same year, in order to duplicate the functionality of the easter_days function return GregorianToJD($month, $day, $year) - GregorianToJD(3,21,$year); } ?> http://php.net/manual/en/function.easter-days.php

« previous php.notes (#141929) next »