You are here

function partial_date_day_of_week in Partial Date 7

Gets day of week, 0 = Sunday through 6 = Saturday.

Pope Gregory removed 10 days - October 5 to October 14 - from the year 1582 and proclaimed that from that time onwards 3 days would be dropped from the calendar every 400 years.

Thursday, October 4, 1582 (Julian) was followed immediately by Friday, October 15, 1582 (Gregorian).

See also

PEAR::Date_Calc

1 call to partial_date_day_of_week()
partial_date_format_component in ./partial_date.module

File

./partial_date.module, line 1799
Defines a date element that allows for any combination of date granularity settings.

Code

function partial_date_day_of_week($year, $month, $day) {
  $greg_correction = 0;
  if ($year < 1582 || $year == 1582 && ($month < 10 || $month == 10 && $day < 15)) {
    $greg_correction = 3;
  }
  if ($month > 2) {
    $month -= 2;
  }
  else {
    $month += 10;
    $year--;
  }
  $day = floor((13 * $month - 1) / 5) + $day + $year % 100 + floor($year % 100 / 4) + floor($year / 100 / 4) - 2 * floor($year / 100) + 77 + $greg_correction;
  return $day - 7 * floor($day / 7);
}