note 34916 deleted from function.date by cece

From: Date: Wed, 20 Aug 2003 13:56:49 +0000
Subject: note 34916 deleted from function.date by cece
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-54760@lists.php.net to get a copy of this message
Note Submitter: michael@michaelthompson.org ---- I needed to be able to calculate Easter # based on the C implementation at # http://www.ely.anglican.org/etc/easter2.c # of the algorithm found here # http://www.oremus.org/liturgy/etc/ktf/app/easter.html function Easter($year) { $golden = ($year % 19) + 1; # Gregorian calendar $dom = ($year + ($year/4) - ($year/100) + ($year/400)) % 7; if( $dom<0 ) $dom += 7; $solar = floor(($year - 1600)/100 - ($year - 1600)/400); $lunar = floor(((($year - 1400)/100) * 8) /25); $pfm = floor((3 - (11 * $golden) + $solar - $lunar) % 30); if( $pfm<0 ) $pfm += 30; if( ($pfm==29) || ($pfm==28 && $golden>11) ) $pfm--; $tmp = floor((4 - $pfm - $dom) % 7); if( $tmp<0 ) $tmp += 7; #$easter = $pfm + $tmp + 1; # for some reason the php implementation # of the algorithm was off by one day in years # evenly divisible by 4 ??? could there be a bug # in mktime? $easter = $pfm + $tmp + ((fmod($year,4)==0)?0:1); if( $easter<11 ) { $mo = 3; $da = $easter + 21; } else { $mo = 4; $da = $easter - 10; } $rtn = mktime(0,0,0,$mo,$da,$year); return $rtn; }

« previous php.notes (#54760) next »