function DatexHejri::fromGregorian in Datex 7.2
* Islamic Calendar *
Parameters
$g_y: * @param $g_m * @param $g_d * @return unknown_type
1 call to DatexHejri::fromGregorian()
- DatexHejri::monthTotalDays in datex_api/
DatexHejri.inc - * @author * Find Number Of Days In This Month
File
- datex_api/
DatexHejri.inc, line 125
Class
- DatexHejri
- @author Sina Salek
Code
function fromGregorian($g_y, $g_m, $g_d) {
$y = $g_y;
$m = $g_m;
$d = $g_d;
if ($y > 1582 || $y == 1582 && $m > 10 || $y == 1582 && $m == 10 && $d > 14) {
$jd = (int) (1461 * ($y + 4800 + (int) (($m - 14) / 12)) / 4) + (int) (367 * ($m - 2 - 12 * (int) (($m - 14) / 12)) / 12) - (int) (3 * (int) (($y + 4900 + (int) (($m - 14) / 12)) / 100) / 4) + $d - 32075;
}
else {
$jd = 367 * $y - (int) (7 * ($y + 5001 + (int) (($m - 9) / 7)) / 4) + (int) (275 * $m / 9) + $d + 1729777;
}
$julianday = $jd;
$l = $jd - 1948440 + 10632;
$n = (int) (($l - 1) / 10631);
$l = $l - 10631 * $n + 354;
$j = (int) ((10985 - $l) / 5316) * (int) (50 * $l / 17719) + (int) ($l / 5670) * (int) (43 * $l / 15238);
$l = $l - (int) ((30 - $j) / 15) * (int) (17719 * $j / 50) - (int) ($j / 16) * (int) (15238 * $j / 43) + 29;
$m = (int) (24 * $l / 709);
$d = $l - (int) (709 * $m / 24);
$y = 30 * $n + $j - 30;
return array(
$y,
$m,
$d,
);
}