Beispiel #1
0
 /**
  * @param integer      $dayOfYear The day-of-year to check, validated as an integer.
  * @param integer|null $year      An optional year to check against, fully validated.
  *
  * @return void
  *
  * @throws DateTimeException If the day-of-year is not valid.
  */
 public static function check($dayOfYear, $year = null)
 {
     if ($dayOfYear < 1 || $dayOfYear > 366) {
         throw DateTimeException::fieldNotInRange(self::NAME, $dayOfYear, 1, 366);
     }
     if ($dayOfYear === 366 && $year !== null) {
         if (!Year::isLeap($year)) {
             throw new DateTimeException("Invalid day-of-year 366 as {$year} is not a leap year");
         }
     }
 }
Beispiel #2
0
 /**
  * @param integer      $dayOfMonth  The day-of-month to check, validated as an integer.
  * @param integer|null $monthOfYear An optional month-of-year to check against, fully validated.
  * @param integer|null $year        An optional year to check against, fully validated.
  *
  * @return void
  *
  * @throws DateTimeException If the day-of-month is not valid.
  */
 public static function check($dayOfMonth, $monthOfYear = null, $year = null)
 {
     if ($dayOfMonth < 1 || $dayOfMonth > 31) {
         throw DateTimeException::fieldNotInRange(self::NAME, $dayOfMonth, 1, 31);
     }
     if ($monthOfYear === null) {
         return;
     }
     $monthLength = MonthOfYear::getLength($monthOfYear, $year);
     if ($dayOfMonth > $monthLength) {
         if ($dayOfMonth === 29) {
             throw new DateTimeException("Invalid date February 29 as {$year} is not a leap year");
         } else {
             $monthName = MonthOfYear::getName($monthOfYear);
             throw new DateTimeException("Invalid date {$monthName} {$dayOfMonth}");
         }
     }
 }
Beispiel #3
0
 /**
  * @param integer $offsetHour The offset-hour to check, validated as an integer.
  *
  * @return void
  *
  * @throws DateTimeException If the offset-hour is not valid.
  */
 public static function check($offsetHour)
 {
     if ($offsetHour < -18 || $offsetHour > 18) {
         throw DateTimeException::fieldNotInRange(self::NAME, $offsetHour, -18, 18);
     }
 }
Beispiel #4
0
 /**
  * @param integer $year The year to check, validated as an integer.
  *
  * @return void
  *
  * @throws DateTimeException If the year is not valid.
  */
 public static function check($year)
 {
     if ($year < self::MIN_VALUE || $year > self::MAX_VALUE) {
         throw DateTimeException::fieldNotInRange(self::NAME, $year, self::MIN_VALUE, self::MAX_VALUE);
     }
 }
Beispiel #5
0
 /**
  * @param integer $minuteOfHour The minute-of-hour to check, validated as an integer.
  *
  * @return void
  *
  * @throws DateTimeException If the minute-of-hour is not valid.
  */
 public static function check($minuteOfHour)
 {
     if ($minuteOfHour < 0 || $minuteOfHour > 59) {
         throw DateTimeException::fieldNotInRange(self::NAME, $minuteOfHour, 0, 59);
     }
 }
Beispiel #6
0
 /**
  * @param integer $nanoOfSecond The nano-of-second to check, validated as an integer.
  *
  * @return void
  *
  * @throws DateTimeException If the nano-of-second is not valid.
  */
 public static function check($nanoOfSecond)
 {
     if ($nanoOfSecond < 0 || $nanoOfSecond > 999999999) {
         throw DateTimeException::fieldNotInRange(self::NAME, $nanoOfSecond, 0, 999999999);
     }
 }
Beispiel #7
0
 /**
  * @param integer $hourOfDay The hour-of-day to check, validated as an integer.
  *
  * @return void
  *
  * @throws DateTimeException If the hour-of-day is not valid.
  */
 public static function check($hourOfDay)
 {
     if ($hourOfDay < 0 || $hourOfDay > 23) {
         throw DateTimeException::fieldNotInRange(self::NAME, $hourOfDay, 0, 23);
     }
 }
Beispiel #8
0
 /**
  * @param integer $secondOfDay The second-of-day to check, validated as an integer.
  *
  * @return void
  *
  * @throws DateTimeException If the second-of-day is not valid.
  */
 public static function check($secondOfDay)
 {
     if ($secondOfDay < 0 || $secondOfDay > 86399) {
         throw DateTimeException::fieldNotInRange(self::NAME, $secondOfDay, 0, 86399);
     }
 }
Beispiel #9
0
 /**
  * @param integer $secondOfMinute The second-of-minute to check, validated as an integer.
  *
  * @return void
  *
  * @throws DateTimeException If the second-of-minute is not valid.
  */
 public static function check($secondOfMinute)
 {
     if ($secondOfMinute < 0 || $secondOfMinute > 59) {
         throw DateTimeException::fieldNotInRange(self::NAME, $secondOfMinute, 0, 59);
     }
 }
Beispiel #10
0
 /**
  * @param integer $monthOfYear The month-of-year to check, validated as an integer.
  *
  * @return void
  *
  * @throws DateTimeException If the month-of-year is not valid.
  */
 public static function check($monthOfYear)
 {
     if ($monthOfYear < 1 || $monthOfYear > 12) {
         throw DateTimeException::fieldNotInRange(self::NAME, $monthOfYear, 1, 12);
     }
 }
 /**
  * @param integer $offsetMinute The offset-minute to check, validated as an integer.
  *
  * @return void
  *
  * @throws DateTimeException If the offset-minute is not valid.
  */
 public static function check($offsetMinute)
 {
     if ($offsetMinute < -59 || $offsetMinute > 59) {
         throw DateTimeException::fieldNotInRange(self::NAME, $offsetMinute, -59, 59);
     }
 }
Beispiel #12
0
 /**
  * @param integer $dayOfWeek The day-of-week to check, validated as an integer.
  *
  * @return void
  *
  * @throws DateTimeException If the day-of-week is not valid.
  */
 public static function check($dayOfWeek)
 {
     if ($dayOfWeek < 1 || $dayOfWeek > 7) {
         throw DateTimeException::fieldNotInRange(self::NAME, $dayOfWeek, 1, 7);
     }
 }
 /**
  * @param integer $offsetSecond The offset-second to check, validated as an integer.
  *
  * @return void
  *
  * @throws DateTimeException If the offset-second is not valid.
  */
 public static function check($offsetSecond)
 {
     if ($offsetSecond < -59 || $offsetSecond > 59) {
         throw DateTimeException::fieldNotInRange(self::NAME, $offsetSecond, -59, 59);
     }
 }
 /**
  * @param integer $offsetSeconds The offset-seconds to check, validated as an integer.
  *
  * @return void
  *
  * @throws DateTimeException If the offset-seconds is not valid.
  */
 public static function check($offsetSeconds)
 {
     if ($offsetSeconds < -self::MAX_SECONDS || $offsetSeconds > self::MAX_SECONDS) {
         throw DateTimeException::fieldNotInRange(self::NAME, $offsetSeconds, -self::MAX_SECONDS, self::MAX_SECONDS);
     }
 }