From e0a9ae63cf873a5529a367f1befec1dfad9b2d6c Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Fri, 16 Oct 2009 05:13:52 +0000 Subject: [PATCH] "fix allowing (at least in the calendar GUI under Linux) to enter curing events starting prior to 1970" --- phpgwapi/inc/class.egw_time.inc.php | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/phpgwapi/inc/class.egw_time.inc.php b/phpgwapi/inc/class.egw_time.inc.php index adfeda39a8..b014c86cab 100644 --- a/phpgwapi/inc/class.egw_time.inc.php +++ b/phpgwapi/inc/class.egw_time.inc.php @@ -91,7 +91,7 @@ class egw_time extends DateTime $type = 'string'; // fall through case 'string': - if (!(is_numeric($time) && $time > 21000000)) + 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 // $time ending in a Z (Zulu or UTC time), is unterstood by DateTime class itself @@ -430,9 +430,21 @@ class egw_time extends DateTime } egw_time::init(); -/* if (isset($_SERVER['SCRIPT_FILENAME']) && $_SERVER['SCRIPT_FILENAME'] == __FILE__) // some tests { + // test timestamps/dates before 1970 + foreach(array('19690811',-3600,'-119322000') as $ts) + { + try { + echo "

egw_time::to($ts,'Y-m-d H:i:s')=".egw_time::to($ts,'Y-m-d H:i:s')."

\n"; + $et = new egw_time($ts); + echo "

egw_time($ts)->format('Y-m-d H:i:s')=".$et->format('Y-m-d H:i:s')."

\n"; + $dt = new DateTime($ts); + echo "

DateTime($ts)->format('Y-m-d H:i:s')=".$dt->format('Y-m-d H:i:s')."

\n"; + } catch(Exception $e) { + echo "

Exception: ".$e->getMessage()."

\n"; + } + } // user time is UTC echo "

user timezone = ".($GLOBALS['egw_info']['user']['preferences']['common']['tz'] = 'UTC').", server timezone = ".date_default_timezone_get()."

\n"; @@ -447,4 +459,4 @@ if (isset($_SERVER['SCRIPT_FILENAME']) && $_SERVER['SCRIPT_FILENAME'] == __FILE_ $ts = egw_time::to(array('full' => '20090627', 'hour' => 10, 'minute' => 0),'ts'); echo "

2009-06-27 10h UTC timestamp=$ts --> server time = ".egw_time::user2server($ts,'')." --> user time = ".egw_time::server2user(egw_time::user2server($ts),'')."

\n"; } -*/ \ No newline at end of file +