Hello everybody,
The following code I found from another place, and it was in Java Script, so I changed it to PHP, and I dont know:
1. how it is work ?
2. is it work at all?
3. need the algorithm and procedure of it...
// PERSIAN_TO_JD -- Determine Julian day from Persian date
$PERSIAN_EPOCH = 1948320.5;
$PERSIAN_WEEKDAYS = Array("Yekshanbeh", "Doshanbeh",
"Seshhanbeh", "Chaharshanbeh",
"Panjshanbeh", "Jomeh", "Shanbeh");
function persian_to_jd($year, $month, $day)
{
$epbase = 0;
$epyear = 0;
$epbase = $year - (($year >= 0) ? 474 : 473);
$epyear = 474 + ($epbase % 2820);
return $day +
(($month <= 7) ?
(($month - 1) * 31) :
((($month - 1) * 30) + 6)
) +
floor((($epyear * 682) - 110) / 2816) +
($epyear - 1) * 365 +
floor($epbase / 2820) * 1029983 +
($PERSIAN_EPOCH - 1);
}
// JD_TO_PERSIAN -- Calculate Persian date from Julian day
function jd_to_persian($jd)
{
$year = 0;
$month = 0;
$day = 0;
$depoch = 0;
$cycle = 0;
$cyear = 0;
$ycycle = 0;
$aux1 = 0;
$aux2 = 0;
$yday = 0;
$jd = floor($jd) + 0.5;
$depoch = $jd - persian_to_jd(475, 1, 1);
$cycle = floor($depoch / 1029983);
$cyear = ($depoch % 1029983);
if ($cyear == 1029982) {
$ycycle = 2820;
} else {
$aux1 = floor($cyear / 366);
$aux2 = ($cyear % 366);
$ycycle = floor(((2134 * $aux1) + (2816 * $aux2) + 2815) / 1028522) +
$aux1 + 1;
}
$year = $ycycle + (2820 * $cycle) + 474;
if ($year <= 0) {
$year--;
}
$yday = ($jd - persian_to_jd($year, 1, 1)) + 1;
$month = ($yday <= 186) ? ceil($yday / 31) : ceil(($yday - 6) / 30);
$day = ($jd - persian_to_jd($year, $month, 1)) + 1;
return Array($year, $month, $day);
}
?>
Thanks...