Exemple #1
0
 /**
  * Returns the smallest LocalDateTime among the given values.
  *
  * @param LocalDateTime ... $times The LocalDateTime objects to compare.
  *
  * @return LocalDateTime The earliest LocalDateTime object.
  *
  * @throws DateTimeException If the array is empty.
  */
 public static function minOf(LocalDateTime ...$times)
 {
     if (!$times) {
         throw new DateTimeException(__METHOD__ . ' does not accept less than 1 parameter.');
     }
     $min = LocalDateTime::max();
     foreach ($times as $time) {
         if ($time->isBefore($min)) {
             $min = $time;
         }
     }
     return $min;
 }
 public function testMax()
 {
     $this->assertLocalDateTimeIs(Year::MAX_VALUE, 12, 31, 23, 59, 59, 999999999, LocalDateTime::max());
 }