Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions lib/Horde/Imap/Client/DateTime.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function __construct($time = null, $tz = null)

/* Bug #14381 Catch malformed offset - which doesn't cause
DateTime to throw exception. */
if (substr(rtrim($time), -5) === ' 0000') {
if ($time !== null && substr(rtrim($time), -5) === ' 0000') {
$time = substr(trim($time), 0, strlen(trim($time)) - 5) . ' +0000';
try {
if ($bug_67118) {
Expand All @@ -48,15 +48,15 @@ public function __construct($time = null, $tz = null)

try {
if ($bug_67118) {
new DateTime($time, $tz);
new DateTime($time === null ? 'now' : $time, $tz);
}
parent::__construct($time, $tz);
parent::__construct($time === null ? 'now' : $time, $tz);
return;
} catch (Exception $e) {}

/* Check for malformed day-of-week parts, usually incorrectly
* localized. E.g. Fr, 15 Apr 2016 15:15:09 +0000 */
if (!preg_match("/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun),/", $time)) {
if ($time !== null && !preg_match("/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun),/", $time)) {
$time = preg_replace("/^(\S*,)/", '', $time, 1, $i);
if ($i) {
try {
Expand All @@ -70,7 +70,7 @@ public function __construct($time = null, $tz = null)
}

/* Bug #5717 - Check for UT vs. UTC. */
if (substr(rtrim($time), -3) === ' UT') {
if ($time !== null && substr(rtrim($time), -3) === ' UT') {
try {
if ($bug_67118) {
new DateTime($time . 'C', $tz);
Expand Down