This repository has been archived by the owner. It is now read-only.

JDate breaks valid DateTime input #705

Closed
wants to merge 2 commits into
from
Jump to file or symbol
Failed to load files and symbols.
+9 −2
Diff settings

Always

Just for now

@@ -113,9 +113,16 @@ public function __construct($date = 'now', $tz = null)
}
}
- // If the date is numeric assume a unix timestamp and convert it.
+ /**
+ * @deprecated
+ * This test is obsolete, because DateTime supports timestamps
+ * if there is a prepended "@" char, so everyone should handle
+ * this issue while calling JDate and not JDate itself
+ */
+ // If the date is numeric and have more than 8 digits
+ // assume a unix timestamp and prepend a '@' char.
date_default_timezone_set('UTC');
- $date = is_numeric($date) ? date('c', $date) : $date;
+ $date = is_numeric($date) && strlen($date) > 8 ? '@' . $date : $date;
// Call the DateTime constructor.
parent::__construct($date, $tz);