You are here

public static function DatexJalali::dayOfWeek in Datex 7.2

returns weekday of the specified day of the year. 1 to 7.

Overrides DatexCalendarIterface::dayOfWeek

2 calls to DatexJalali::dayOfWeek()
DatexJalali::calendarFormat in datex_api/DatexJalali.inc
Calculate format values which parent won't handle.
DatexJalali::convert in datex_api/DatexJalali.inc
Converts a Gregorian date to Jalali.

File

datex_api/DatexJalali.inc, line 436
Jalali calendar for datex.

Class

DatexJalali
Jalali calendar for datex.

Code

public static function dayOfWeek($year, $dayOfYear = 0) {
  $rasad = self::observationYear($year);
  $count2820 = floor($rasad / 2820);
  $mod2820 = $rasad % 2820;
  $count128 = floor($mod2820 / 128);
  $mod128 = $mod2820 % 128;
  $leapCount = 0;
  while ($mod128 > self::$khayamii[$leapCount]) {
    $leapCount++;
  }
  $yearStartDay = ($count2820 + 1) * 3 + $count128 * 5 + $mod128 + $leapCount;
  if ($dayOfYear > 0) {
    $dayOfYear--;
  }
  return ($yearStartDay + $dayOfYear) % 7;
}