Bug #68909 [NoF]: function easter_date() not correct 1970-1989 years
| From: | requinix@php.net | Date: | Tue, 14 Jan 2020 18:46:59 +0000 |
| Subject: | Bug #68909 [NoF]: function easter_date() not correct 1970-1989 years | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-224900@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=68909&edit=1
ID: 68909
Updated by: requinix@php.net
Reported by: andris dot petrams at gmail dot com
Summary: function easter_date() not correct 1970-1989 years
Status: No Feedback
Type: Bug
Package: Calendar related
Operating System: any
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
Same questions for you @rui: did you see the note in the documentation, and does the code in it give
the expected output?
Previous Comments:
------------------------------------------------------------------------
[2020-01-14 10:52:31] rui at bitpt dot com
Same for all years. PHP 7.2, 7.3 and 7.4
------------------------------------------------------------------------
[2015-01-25 12:44:56] andris dot petrams at gmail dot com
easter_date(): 1970-03-28T23:00:00+02:00 (Saturday) Europe/Helsinki
My Function: 1970-03-29T00:00:00+02:00 (Sunday) Europe/Helsinki
easter_date(): 1971-04-10T23:00:00+02:00 (Saturday) Europe/Helsinki
My Function: 1971-04-11T00:00:00+02:00 (Sunday) Europe/Helsinki
easter_date(): 1972-04-01T23:00:00+02:00 (Saturday) Europe/Helsinki
My Function: 1972-04-02T00:00:00+02:00 (Sunday) Europe/Helsinki
easter_date(): 1973-04-21T23:00:00+02:00 (Saturday) Europe/Helsinki
My Function: 1973-04-22T00:00:00+02:00 (Sunday) Europe/Helsinki
easter_date(): 1974-04-13T23:00:00+02:00 (Saturday) Europe/Helsinki
My Function: 1974-04-14T00:00:00+02:00 (Sunday) Europe/Helsinki
easter_date(): 1975-03-29T23:00:00+02:00 (Saturday) Europe/Helsinki
My Function: 1975-03-30T00:00:00+02:00 (Sunday) Europe/Helsinki
easter_date(): 1976-04-17T23:00:00+02:00 (Saturday) Europe/Helsinki
My Function: 1976-04-18T00:00:00+02:00 (Sunday) Europe/Helsinki
easter_date(): 1977-04-09T23:00:00+02:00 (Saturday) Europe/Helsinki
My Function: 1977-04-10T00:00:00+02:00 (Sunday) Europe/Helsinki
easter_date(): 1978-03-25T23:00:00+02:00 (Saturday) Europe/Helsinki
My Function: 1978-03-26T00:00:00+02:00 (Sunday) Europe/Helsinki
easter_date(): 1979-04-14T23:00:00+02:00 (Saturday) Europe/Helsinki
My Function: 1979-04-15T00:00:00+02:00 (Sunday) Europe/Helsinki
easter_date(): 1980-04-05T23:00:00+02:00 (Saturday) Europe/Helsinki
My Function: 1980-04-06T00:00:00+02:00 (Sunday) Europe/Helsinki
easter_date(): 1981-04-18T23:00:00+03:00 (Saturday) Europe/Helsinki
My Function: 1981-04-19T00:00:00+03:00 (Sunday) Europe/Helsinki
easter_date(): 1982-04-10T23:00:00+03:00 (Saturday) Europe/Helsinki
My Function: 1982-04-11T00:00:00+03:00 (Sunday) Europe/Helsinki
easter_date(): 1983-04-02T23:00:00+03:00 (Saturday) Europe/Helsinki
My Function: 1983-04-03T00:00:00+03:00 (Sunday) Europe/Helsinki
easter_date(): 1984-04-21T23:00:00+03:00 (Saturday) Europe/Helsinki
My Function: 1984-04-22T00:00:00+03:00 (Sunday) Europe/Helsinki
easter_date(): 1985-04-06T23:00:00+03:00 (Saturday) Europe/Helsinki
My Function: 1985-04-07T00:00:00+03:00 (Sunday) Europe/Helsinki
easter_date(): 1986-03-29T23:00:00+02:00 (Saturday) Europe/Helsinki
My Function: 1986-03-30T00:00:00+02:00 (Sunday) Europe/Helsinki
easter_date(): 1987-04-18T23:00:00+03:00 (Saturday) Europe/Helsinki
My Function: 1987-04-19T00:00:00+03:00 (Sunday) Europe/Helsinki
easter_date(): 1988-04-02T23:00:00+03:00 (Saturday) Europe/Helsinki
My Function: 1988-04-03T00:00:00+03:00 (Sunday) Europe/Helsinki
easter_date(): 1989-03-25T23:00:00+02:00 (Saturday) Europe/Helsinki
My Function: 1989-03-26T00:00:00+02:00 (Sunday) Europe/Helsinki
easter_date(): 1990-04-15T00:00:00+03:00 (Sunday) Europe/Helsinki
My Function: 1990-04-15T00:00:00+03:00 (Sunday) Europe/Helsinki
------------------------------------------------------------------------
[2015-01-25 12:41:17] requinix@php.net
Okay, you decided to do the calculations yourself, that's fine. If you're still interested
in resolving your original problem then feel free to answer my earlier question.
------------------------------------------------------------------------
[2015-01-25 12:30:05] andris dot petrams at gmail dot com
My solve for this:
<?php
function EasterDate($X){ // X = year to compute
$str=$X;
if($X>0){
$K = floor($X / 100); // Secular number
$M = ceil(15 + (3 * $K + 3) / 4 - (8 * $K + 13) / 25); // Secular Moon shift
$S = ceil(2 - (3 * $K + 3) / 4); // Secular sun shift
$A = $X % 19; // Moon parameter
$D = (19 * $A + $M) % 30; // Seed for 1st full Moon in spring
$R = floor($D / 29 + ($D / 28 - $D / 29) * ($A / 11)); // Calendarian correction quantity
$OG = 21 + $D - $R; // Easter limit
$SZ = 7 - floor($X + $X / 4 + $S) % 7; // 1st sunday in March
$OE = 7 - ($OG - $SZ) % 7; // Distance Easter sunday from Easter limit in days
$dt = (((($OG + $OE)%31)==0)?31:(($OG + $OE)%31));
$mn = ((($OG + $OE)>31)?4:3);
return new DateTime($X."-".$mn."-".$dt);
//return $date->format('c (l) e');
}
return $str;
}
echo '<table border="1">';
for($i=1970; $i<2038; $i++){
echo '<tr><td>'.date("c (l) e", easter_date($i)).'</td>
<td>'.EasterDate($i)->format('c (l)
e').'</td></tr>'; }
echo '<table>';
?>
------------------------------------------------------------------------
[2015-01-25 11:47:38] requinix@php.net
There is a Note towards the end of documentation for easter_date(). What happens when you try the
sample code it provides?
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=68909
--
Edit this bug report at https://bugs.php.net/bug.php?id=68909&edit=1