Bug #12766 Updated: easter_days breaks for year before 1753
| From: | markonen@php.net | Date: | Sun, 12 May 2002 15:15:03 +0000 |
| Subject: | Bug #12766 Updated: easter_days breaks for year before 1753 | ||
| References: | 1 | Groups: | php.bugs php.doc |
| Request: | Send a blank email to php-bugs+get-7476@lists.php.net to get a copy of this message | ||
ID: 12766
Updated by: markonen@php.net
Reported By: martin@diers.cc
Status: Open
-Bug Type: Feature/Change Request
+Bug Type: Documentation problem
Operating System: Linux 2.4.x
PHP Version: 4.0.6
New Comment:
This issue has been resolved in the CVS version (4.3.0-
dev). You can fetch a snapshot with the improved
functionality from http://snaps.php.net/
An optional second parameter was added to easter_days().
It can take one of four values:
CAL_EASTER_DEFAULT for the current (and default)
functionality, CAL_EASTER_ROMAN for continental european
behaviour (changes the Julian > Gregorian cut off date from
1752 to 1582) and CAL_EASTER_ALWAYS_JULIAN or
CAL_EASTER_ALWAYS_GREGORIAN for forcing the calendar
regardless of date.
I'm reclassifying this as a documentation problem in order
to get the new feature documented.
Thank you for your bug report, and for helping us make PHP
better.
Previous Comments:
------------------------------------------------------------------------
[2002-05-12 03:18:59] mfischer@php.net
Feature Request -> Status: Open.
------------------------------------------------------------------------
[2002-05-12 00:00:03] php-bugs@lists.php.net
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
------------------------------------------------------------------------
[2002-04-09 18:53:52] jimw@php.net
yes, the fallibility of this function is well-documented.
reclassifying as a feature request.
------------------------------------------------------------------------
[2001-08-15 14:25:16] martin@diers.cc
Based on the documentation for the easter_days command, this behaviour
would appear to be deliberate. It seems that the easter calculation is
changed over to the Julian formula for all dates prior to 1753, because
that is the year that Britain and its colonies finally switched to the
Gregorian calendar. However, that does not change the fact that since
1582, the rest of Europe was using the Gregorian calendar.
This being the case, it would make since to be able to calculate the
date of Easter for the range 1582-1752 using either the Julian formula
(which is simply based on cycles of the moon) or the Gregorian formula
(which is far more complex). To implement this, an optional switch
could be added to the easter_days function which defaults to the Julian
formula for that date range, but allows the user to specify the
Gregorian formula instead.
------------------------------------------------------------------------
[2001-08-15 10:51:32] martin@diers.cc
The easter_days function returns bad data for years <= 1752. Here is a
way to verify. Because Easter always falls on a Sunday, the following
function should always return "Sunday":
function EasterDOW($year) {
$jdayc = easter_days($year);
$jdmar21 = gregoriantojd(3, 21, $year);
$jdeaster = $jdmar21 + $jdayc;
return JDDayOfWeek($jdeaster, 1);
}
The formula for calculating easter has been the same since 1582. The
standerd Delambre Easter algorithm is able to generate the date of
easter for any gregorian date after 1582. The following function may be
used to duplicate the functionality of easter_days for any date since
1582:
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);
}
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=12766&edit=1