You are here

private static function DatexPoorMansJaliliCalendar::validate_ in Datex 8

2 calls to DatexPoorMansJaliliCalendar::validate_()
DatexPoorMansJaliliCalendar::parse in src/Datex/DatexPoorMansJaliliCalendar.php
Is supposed to parse a date string into date value.
DatexPoorMansJaliliCalendar::validate in src/Datex/DatexPoorMansJaliliCalendar.php

File

src/Datex/DatexPoorMansJaliliCalendar.php, line 58
Fallback calendar implementation in case php-intl is not avaiable.

Class

DatexPoorMansJaliliCalendar
Jalali calendar for datex.

Namespace

Drupal\datex\Datex

Code

private static function validate_($year, $month, $day) {
  $zero = TRUE;
  $year = intval($year);
  $month = intval($month);
  $day = intval($day);
  if ($year < 0 || $year === 0 && $zero) {
    return t('Year out of range');
  }
  if ($month < 0 || 12 < $month || $month === 0 && $zero) {
    return t('Month out of range');
  }
  if ($day === 0 && $zero || $day < 0 || 31 < $day || $month > 6 && $day > 30 || $month === 12 && $day > 29) {
    return t('Day out of range');
  }
  return FALSE;
}