X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FUtil%2FDateTimeFormat.php;h=e293857acdd14a937fbc45b19bffe31fc4aecfce;hb=596b934a02320eb889998ea56168ac1b60adf7ce;hp=10810da0342798193361093624edf4b5f4e9ff6e;hpb=9b37f5c0855c8071075fa3ce49b7e9c38f2c6a2e;p=friendica.git diff --git a/src/Util/DateTimeFormat.php b/src/Util/DateTimeFormat.php index 10810da034..e293857acd 100644 --- a/src/Util/DateTimeFormat.php +++ b/src/Util/DateTimeFormat.php @@ -90,12 +90,12 @@ class DateTimeFormat { // Defaults to UTC if nothing is set, but throws an exception if set to empty string. // Provide some sane defaults regardless. - if ($from === '') { - $from = 'UTC'; + if ($tz_from === '') { + $tz_from = 'UTC'; } - if ($to === '') { - $to = 'UTC'; + if ($tz_to === '') { + $tz_to = 'UTC'; } if (($s === '') || (!is_string($s))) { @@ -109,6 +109,9 @@ class DateTimeFormat * months and days always start with 1. */ if (substr($s, 0, 10) <= '0001-01-01') { + if ($s < '0000-00-00') { + $s = '0000-00-00'; + } $d = new DateTime($s . ' + 32 days', new DateTimeZone('UTC')); return str_replace('1', '0', $d->format($format)); } @@ -122,7 +125,7 @@ class DateTimeFormat try { $d = new DateTime($s, $from_obj); } catch (Exception $e) { - logger('datetime_convert: exception: ' . $e->getMessage()); + logger('DateTimeFormat::convert: exception: ' . $e->getMessage()); $d = new DateTime('now', $from_obj); }