plugins/libkolab

Aleksander Machniak machniak at kolabsys.com
Sat Aug 24 16:13:14 CEST 2013


 plugins/libkolab/lib/kolab_format.php |   16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

New commits:
commit 2f96ed2b97edf07656ed37b63c7588d051bebe93
Author: Aleksander Machniak <machniak at kolabsys.com>
Date:   Sat Aug 24 16:12:34 2013 +0200

    Catch exception on DateTime oparations (Bug #2147)

diff --git a/plugins/libkolab/lib/kolab_format.php b/plugins/libkolab/lib/kolab_format.php
index 66ba380..f59518c 100644
--- a/plugins/libkolab/lib/kolab_format.php
+++ b/plugins/libkolab/lib/kolab_format.php
@@ -104,13 +104,17 @@ abstract class kolab_format
         }
         $result = new cDateTime();
 
-        // got a unix timestamp (in UTC)
-        if (is_numeric($datetime)) {
-            $datetime = new DateTime('@'.$datetime, new DateTimeZone('UTC'));
-            if ($tz) $datetime->setTimezone($tz);
+        try {
+            // got a unix timestamp (in UTC)
+            if (is_numeric($datetime)) {
+                $datetime = new DateTime('@'.$datetime, new DateTimeZone('UTC'));
+                if ($tz) $datetime->setTimezone($tz);
+            }
+            else if (is_string($datetime) && strlen($datetime)) {
+                $datetime = new DateTime($datetime, $tz ?: null);
+            }
         }
-        else if (is_string($datetime) && strlen($datetime))
-            $datetime = new DateTime($datetime, $tz ?: null);
+        catch (Exception $e) {}
 
         if ($datetime instanceof DateTime) {
             $result->setDate($datetime->format('Y'), $datetime->format('n'), $datetime->format('j'));




More information about the commits mailing list