stripTime($time); parent::__construct($time, $tz); return; } $relative = static::hasRelativeKeywords($time); if (!empty($time) && $time !== 'now' && !$relative) { $time = $this->stripTime($time); parent::__construct($time, $tz); return; } $testNow = clone $testNow; if ($relative) { $time = $this->stripRelativeTime($time); if (strlen($time) > 0) { $testNow = $testNow->modify($time); } } if ($tz !== $testNow->getTimezone()) { $testNow = $testNow->setTimezone($tz === null ? date_default_timezone_get() : $tz); } $time = $testNow->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); } /** * Return properties for debugging. * * @return array */ public function __debugInfo() { // Conditionally add properties if state exists to avoid // errors when using a debugger. $vars = get_object_vars($this); $properties = [ 'hasFixedNow' => static::hasTestNow(), ]; if (isset($vars['date'])) { $properties['date'] = $this->format('Y-m-d'); } return $properties; } }