mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-02-17 02:41:02 +01:00
if DateTime::__construct() throws error for strings interpreted as Ymd, catch it and try again as timestamp
This commit is contained in:
parent
b97ba82f27
commit
99f88b97f2
@ -97,13 +97,21 @@ class egw_time extends DateTime
|
|||||||
case 'string':
|
case 'string':
|
||||||
if (!(is_numeric($time) && ($time > 21000000 || $time < 19000000)))
|
if (!(is_numeric($time) && ($time > 21000000 || $time < 19000000)))
|
||||||
{
|
{
|
||||||
if (is_numeric($time) && strlen($time) == 8) $time .= 'T000000'; // 'Ymd' string used in calendar to represent a date
|
$t_str = $time;
|
||||||
|
if (is_numeric($time) && strlen($time) == 8) $t_str .= 'T000000'; // 'Ymd' string used in calendar to represent a date
|
||||||
// $time ending in a Z (Zulu or UTC time), is unterstood by DateTime class itself
|
// $time ending in a Z (Zulu or UTC time), is unterstood by DateTime class itself
|
||||||
parent::__construct($time,$tz);
|
try {
|
||||||
break;
|
parent::__construct($t_str,$tz);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
catch(Exception $e) {
|
||||||
|
// if string is nummeric, ignore the exception and treat string as timestamp
|
||||||
|
if (!is_numeric($time)) throw $e;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$type = 'integer';
|
$type = 'integer';
|
||||||
// fall through for timestamps
|
// fall through for timestamps
|
||||||
|
case 'double': // 64bit integer (timestamps > 2038) are treated on 32bit systems as double
|
||||||
case 'integer':
|
case 'integer':
|
||||||
/* ToDo: Check if PHP5.3 setTimestamp does the same, or always expects UTC timestamp
|
/* ToDo: Check if PHP5.3 setTimestamp does the same, or always expects UTC timestamp
|
||||||
if (PHP_VERSION >= 5.3)
|
if (PHP_VERSION >= 5.3)
|
||||||
|
Loading…
Reference in New Issue
Block a user