From f690bbb3a94b899776c390b688093a0b14266cd4 Mon Sep 17 00:00:00 2001 From: "J. King" Date: Thu, 19 Oct 2017 22:39:39 -0400 Subject: [PATCH] Alias Date::normalize to ValueInfo::normalize --- lib/Misc/Date.php | 37 ++----------------------------------- 1 file changed, 2 insertions(+), 35 deletions(-) diff --git a/lib/Misc/Date.php b/lib/Misc/Date.php index cbde60fd..37a9587e 100644 --- a/lib/Misc/Date.php +++ b/lib/Misc/Date.php @@ -35,41 +35,8 @@ class Date { return $date->format($f); } - public static function normalize($date, string $inFormat = null, bool $inLocal = false) { - if ($date instanceof \DateTimeInterface) { - return $date; - } elseif (is_numeric($date)) { - $time = (int) $date; - } elseif ($date===null) { - return null; - } elseif (is_string($date)) { - try { - $tz = (!$inLocal) ? new \DateTimeZone("UTC") : null; - if (!is_null($inFormat)) { - switch ($inFormat) { - case 'http': $f = "D, d M Y H:i:s \G\M\T"; break; - case 'iso8601': $f = "Y-m-d\TH:i:sP"; break; - case 'sql': $f = "Y-m-d H:i:s"; break; - case 'date': $f = "Y-m-d"; break; - case 'time': $f = "H:i:s"; break; - default: $f = $inFormat; break; - } - return \DateTime::createFromFormat("!".$f, $date, $tz); - } else { - return new \DateTime($date, $tz); - } - } catch (\Throwable $e) { - return null; - } - } elseif (is_bool($date)) { - return null; - } else { - $time = (int) $date; - } - $tz = (!$inLocal) ? new \DateTimeZone("UTC") : null; - $d = new \DateTime("now", $tz); - $d->setTimestamp($time); - return $d; + public static function normalize($date, string $inFormat = null) { + return ValueInfo::normalize($date, ValueInfo::T_DATE, $inFormat); } public static function add(string $interval, $date = null): \DateTimeInterface {