From 3f9d70a484608480bf05bec0c9191d803b8f7726 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Wed, 11 Jan 2012 01:07:18 +0000 Subject: [PATCH] automatic conversation of not set DB timestamps returned by MySQL as "0000-00-00 00:00:00" to null --- etemplate/inc/class.date_widget.inc.php | 2 +- etemplate/inc/class.so_sql.inc.php | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/etemplate/inc/class.date_widget.inc.php b/etemplate/inc/class.date_widget.inc.php index f76f144ea6..76c9ce878a 100644 --- a/etemplate/inc/class.date_widget.inc.php +++ b/etemplate/inc/class.date_widget.inc.php @@ -112,7 +112,7 @@ class date_widget // automatic convert db timestamps to unix timestamps, our db class does the reverse on writing them if ($value && !$data_format && !is_numeric($value) && ($v = strtotime($value))) { - $value = $v; + $value = $value === '0000-00-00 00:00:00' ? null : $v; } // for date-(time|hour)only widgets we distinct between between 0 and ''/null timestamps if (!$value && ($type != 'date-timeonly' && $type != 'date-houronly' || (string)$value === '')) diff --git a/etemplate/inc/class.so_sql.inc.php b/etemplate/inc/class.so_sql.inc.php index febaf37ee6..042891c501 100644 --- a/etemplate/inc/class.so_sql.inc.php +++ b/etemplate/inc/class.so_sql.inc.php @@ -375,7 +375,14 @@ class so_sql { if (isset($data[$name]) && $data[$name]) { - $data[$name] = egw_time::server2user($data[$name],$this->timestamp_type); + if ($data[$name] === '0000-00-00 00:00:00') + { + $data[$name] = null; + } + else + { + $data[$name] = egw_time::server2user($data[$name],$this->timestamp_type); + } } } }