091 Informatika i religija

function tmEaster($year,$EasterDay=0)
{

$golden = ($year % 19) + 1;
if( $year <= 1752 )
{
# Julian calendar
$dom = floor(($year + ($year/4) + 5) % 7);
if( $dom<0 ) $dom += 7;

$pfm = floor((3 – (11 * $golden) – 7) % 30);
}
else
{
# 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 + (date(“L”,mktime(0,0,0,1,1,$year))!=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);

if( $EasterDay!=0 )
{
$mo = date(“n”,$rtn);
$da = date(“j”,$rtn);

switch( $EasterDay )
{
case 1: # Palm Sunday
$rtn = mktime(0,0,0,$mo,$da – 7,$year);
break;
case 2: # $Mardi Gras
$rtn = mktime(0,0,0,$mo,$da – 47,$year);
break;
case 3: # Ash Wednesday
$rtn = mktime(0,0,0,$mo,$da – 46,$year);
break;
case 4: # Holy Thursday
$rtn = mktime(0,0,0,$mo,$da – 3,$year);
break;
case 5: # Good Friday
$rtn = mktime(0,0,0,$mo,$da – 2,$year);
break;
case 6: # Passover
$rtn = mktime(0,0,0,$mo,$da – 6,$year);
break;
case 7: # Pentecost
$rtn = mktime(0,0,0,$mo,$da + 49,$year);
break;
case 8: # Ascension
$rtn = mktime(0,0,0,$mo,$da + (49 – 10),$year);
break;
case 9: # Pentecost
$rtn = mktime(0,0,0,$mo,$da + (49 + 7),$year);
break;
case 10: # Rogation Sunday
$rtn = mktime(0,0,0,$mo,$da + 35,$year);
break;
case 11: # Corpus Christi
$rtn = mktime(0,0,0,$mo,$da + (49 + 11),$year);
break;
case 13: # Quasimodo Sunday
$rtn = mktime(0,0,0,$mo,$da + 7,$year);
break;
}
}
return $rtn;
}