You are here

function hijri_calc in Hijri 8

Same name and namespace in other branches
  1. 7 hijri.module \hijri_calc()

Calculate Hijri date from the given Gregorian by converting through Julian day. For more checkout these links: http://php.net/manual/en/ref.calendar.php#54234 http://sourceforge.net/p/ar-php/code/47/tree/I18N/Arabic/Date.php#l442

1 call to hijri_calc()
hijri in ./hijri.module
Retrive Hijri date from given format and timestamp.

File

./hijri.module, line 136
hijri.module This module convert to Hijri date in nodes,comments and a block.

Code

function hijri_calc($y, $m, $d) {
  $jd = cal_to_jd(CAL_GREGORIAN, $m, $d, $y);
  $jd = $jd - 1948440 + 10632;
  $n = (int) (($jd - 1) / 10631);
  $jd = $jd - 10631 * $n + 354;
  $j = (int) ((10985 - $jd) / 5316) * (int) (50 * $jd / 17719) + (int) ($jd / 5670) * (int) (43 * $jd / 15238);
  $jd = $jd - (int) ((30 - $j) / 15) * (int) (17719 * $j / 50) - (int) ($j / 16) * (int) (15238 * $j / 43) + 29;
  $m = (int) (24 * $jd / 709);
  $d = $jd - (int) (709 * $m / 24);
  $y = 30 * $n + $j - 30;
  return array(
    $y,
    $m,
    $d,
  );
}