note 47249 added to function.easter-date

From: Date: Mon, 08 Nov 2004 16:17:16 +0000
Subject: note 47249 added to function.easter-date
Groups: php.notes 
Request: Send a blank email to php-notes+get-80289@lists.php.net to get a copy of this message
The algorithm from Bigtree is correct if you add some (int) cast <?php function easter_date ($Year) { /* G is the Golden Number-1 H is 23-Epact (modulo 30) I is the number of days from 21 March to the Paschal full moon J is the weekday for the Paschal full moon (0=Sunday, 1=Monday, etc.) L is the number of days from 21 March to the Sunday on or before the Paschal full moon (a number between -6 and 28) */ $G = $Year % 19; $C = (int)($Year / 100); $H = (int)($C - (int)($C / 4) - (int)((8*$C+13) / 25) + 19*$G + 15) % 30; $I = (int)$H - (int)($H / 28)*(1 - (int)($H / 28)*(int)(29 / ($H + 1))*((int)(21 - $G) / 11)); $J = ($Year + (int)($Year/4) + $I + 2 - $C + (int)($C/4)) % 7; $L = $I - $J; $m = 3 + (int)(($L + 40) / 44); $d = $L + 28 - 31 * ((int)($m / 4)); $y = $Year; $E = mktime(0,0,0, $m, $d, $y); return $E; } ?> ---- Manual Page -- http://www.php.net/manual/en/function.easter-date.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+47249 Delete -- http://master.php.net/manage/user-notes.php?action=delete+47249&report=yes Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+47249&report=yes&reason=bad+code Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+47249&report=yes&reason=spam Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+47249&report=yes&reason=useless+example Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+47249&report=yes&reason=contains+commercial+links Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+47249&report=yes&reason=useless+note Reject -- http://master.php.net/manage/user-notes.php?action=reject+47249&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#80289) next »