stripTime($time); return parent::__construct($time, $tz); } $relative = static::hasRelativeKeywords($time); if (!empty($time) && $time !== 'now' && !$relative) { $time = $this->stripTime($time); return parent::__construct($time, $tz); } $testInstance = clone static::getTestNow(); if ($relative) { $testInstance = $testInstance; $testInstance = $testInstance->modify($time); } if ($tz !== $testInstance->getTimezone()) { $testInstance = $testInstance->setTimezone($tz === null ? date_default_timezone_get() : $tz); } $time = $testInstance->format('Y-m-d 00:00:00'); parent::__construct($time, $tz); } /** * Create a new immutable instance from current mutable instance. * * @return \Cake\Chronos\Date */ public function toImmutable() { return Date::instance($this); } }