Returns the highest LocalDate among the given values.

@param LocalDate[] $dates The LocalDate objects to compare.

@return LocalDate The latest LocalDate object.

@throws DateTimeException If the array is empty.
542218
public static function maxOf(LocalDate ...$dates) : LocalDate
    {
        if (! $dates) {
            throw new DateTimeException(__METHOD__ . ' does not accept less than 1 parameter.');
        }

        $max = LocalDate::min();

        foreach ($dates as $time) {
            if ($time->isAfter($max)) {
                $max = $time;
            }
        }

        return $max;
    }
822225
public function getPublishedDate($dates)
    {
        $defaults = [
            "revision" => [],
            "published" => null,
            "updated" => null,
            "created" => null,
        ];
        $dates = array_merge($defaults, $dates);
        
        if ($dates["revision"]) {
            return [t("Latest revision"), key($dates["revision"])];
        } elseif ($dates["published"]) {
            return [t("Published"), $dates["published"]];
        } elseif ($dates["updated"]) {
            return [t("Updated"), $dates["updated"]];
        } elseif ($dates["created"]) {
            return [t("Created"), $dates["created"]];
        }

        return [t("Missing pubdate."), null];
    }
215823
LocalDate endDate() {
        int ordinal = ordinal(eraValue);
        JapaneseEra[] eras = values();
        if (ordinal >= eras.length - 1) {
            return LocalDate.MAX;
        }
        return eras[ordinal + 1].startDate().minusDays(1);
    }
257801
public function max(Date $dt = null)
    {
        $dt = $dt ?: static::now($this->getTimezone());

        return $this->isAfter($dt) ? clone $this : clone $dt;
    }
899528
public function minusDays(int $days) : LocalDateTime
    {
        if ($days === 0) {
            return $this;
        }

        return new LocalDateTime($this->date->minusDays($days), $this->time);
    }
571029
function getFirstLastDate($dateA, $dFormat = "Y/m/d") {

//    $fDate = $lDate = date("m/d/y",time());
        $fDate = $lDate = date($dFormat, time());
        asort($dateA); // TODO
        $i = 0;
        $maxItem = count($dateA);
        foreach ($dateA as $k => $one) {
            if ($i == 0)
                $firstDate = $k;
            if ($i == $maxItem - 1)
                $lastDate = $k;
            $i++;
        }
        $fDate = date($dFormat, strtotime($firstDate));
        $lDate = date($dFormat, strtotime($lastDate));
        return array($fDate, $lDate);
    }
882835
public function contains(LocalDate $date) : bool
    {
        return ! ($date->isBefore($this->startDate) || $date->isAfter($this->endDate));
    }
36421
public function sinceAlmost(Date $date = null)
	{
		return $this->datetime->sinceAlmost(self::cast($date));
	}
22931
public static function compare($date1, $date2): int
    {
        $d1 = static::create($date1);
        $d2 = static::create($date2);

        return ($d1 > $d2) ? static::DATETIME_GREATER : (($d1 < $d2) ? static::DATETIME_LESS : static::DATETIME_EQUAL);
    }
197298
public static function toFormat($date, $format, $local = false)
    {
        if (is_string($date)) {
            $date = new static($date);
        }

        return $date->format($format, $local);
    }
818137
public function getUserDate($date)
    {
        $date = DBDatetime::create()->setValue($date);
        $member = Security::getCurrentUser();
        return $date->FormatFromSettings($member);
    }
258743
public static function guessFrom($date)
    {
        if ($date instanceof DateTime) {
            return (new static())->setTimestamp($date->getTimestamp())->setTimezone($date->getTimezone());
        }

        if (is_numeric($date)) {
            return (new static())->setTimestamp((int) $date);
        }

        if (is_object($date) && method_exists($date, 'getTimestamp')) {
            return (new static())->setTimestamp($date->getTimestamp());
        }

        if (!Type::isStringLike($date)) {
            $typeName = Type::of($date);
            throw new InvalidArgumentException("No idea how to cast $typeName to DateTime");
        }

        $date = (string) $date;

        if ($dateTime = date_create($date)) {
            return $dateTime;
        }

        throw new InvalidArgumentException("No idea how to cast $date to DateTime");
    }
731372
private static function _utcZeroDateTime($date){

		$date = static::_nullValue($date);

		if($date === null){

			return $date;
		}

		$UTC = new DateTimeZone('UTC');
		$Date = new DateTime($date, $UTC);
		$Date->setTimezone($UTC);

		return $Date;
	}
1018951
public function dateIsEarlier(\DateTime $date) {
    $dateEarlier = FALSE;

    $t1 = $this->start_date->getTimeStamp();

    $t3 = $date->getTimeStamp();

    if ($t3 < $t1) {
      $dateEarlier = TRUE;
    }

    return $dateEarlier;
  }
250349
public function cleanDate($date)
    {
        $response = $this->query($this->prepareUri('clean/birthdate'), [$date]);
        $result = $this->populate(new Date, $response);
        if (!$result instanceof Date) {
            throw new RuntimeException('Unexpected populate result: ' . get_class($result). '. Expected: ' . Date::class);
        }

        return $result;
    }
410526
public function getStringByDate(DateTime $date)
    {
        $dateNow = new DateTime();

        if ($dateNow < $date) {
            return 'Future date not implemented.';
        }

        if ($date->format('Ymd') === $dateNow->format('Ymd')) {
            return $this->getTranslator()->trans('time.today');
        }

        if ($date->format('Ymd') === ((new DateTime('yesterday'))->format('Ymd'))) {
            return $this->getTranslator()->trans('time.yesterday');
        }

        $diffDays = ceil(($dateNow->getTimestamp() - $date->getTimestamp()) / 86400);

        if (7 > $diffDays) {
            return $this->getTranslator()->trans('time.days_ago', [
                '{days}' => $diffDays,
            ]);
        }

        if ($date->format('W') === (new DateTime('-1 Week'))->format('W')) {
            return $this->getTranslator()->trans('time.last_week');
        }

        if (28 > $diffDays) {
            return $this->getTranslator()->trans('time.weeks_ago', [
                '{weeks}' => floor($diffDays / 7),
            ]);
        }

        if ($date->format('Ym') === (new DateTime('-1 month'))->format('Ym')) {
            return $this->getTranslator()->trans('time.last_month');
        }

        if ($date->format('Y') === ($dateNow->format('Y') - 1)) {
            return $this->getTranslator()->trans('time.last_year');
        }

        return $this->getTranslator()->trans('time.years_ago', [
            '{years}' => $dateNow->format('Y') - $date->format('Y'),
        ]);
    }
1055953
protected function datesFromAjax($ajaxDates)
    {
        $dates = [];
        $dateRegex = '/\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/';

        if (null !== $ajaxDates) {
            if (!is_array($ajaxDates)) {
                if(preg_match($dateRegex, $ajaxDates)) {
                    $dates = [$ajaxDates];
                }
            } else {
                foreach ($ajaxDates as $i => $date) {
                    if (preg_match($dateRegex, $date)) {
                        $dates[] = Carbon::createFromFormat('Y-m-d H:i:s', $date);
                    } elseif (empty($date)) {
                        if($i == 0) {
                            $dates[] = Carbon::createFromFormat('Y-m-d H:i:s', '0000-00-00 00:00:00');
                        } else {
                            $dates[] = Carbon::createFromFormat('Y-m-d H:i:s', '2999-12-31 23:59:59');
                        }
                    } else {
                        $dates = [];
                        break;
                    }
                }
            }
        }
        return $dates;
    }