summaryrefslogtreecommitdiff
path: root/program
diff options
context:
space:
mode:
authorthomascube <thomas@roundcube.net>2012-01-06 09:40:32 +0000
committerthomascube <thomas@roundcube.net>2012-01-06 09:40:32 +0000
commit87986cfdb99e3fe67e9711611361f034e27311b3 (patch)
tree3c304d2736631abc86d7ca600d9ca3e6e6855147 /program
parentac78df34178e679f9a3aded37d81bb760f3f5912 (diff)
Handle DateTime exceptions
Diffstat (limited to 'program')
-rw-r--r--program/include/main.inc24
1 files changed, 17 insertions, 7 deletions
diff --git a/program/include/main.inc b/program/include/main.inc
index 66de2e5d8..b0736625a 100644
--- a/program/include/main.inc
+++ b/program/include/main.inc
@@ -1062,15 +1062,25 @@ function format_date($date, $format=NULL, $convert=true)
if (empty($ts))
return '';
- $date = new DateTime("@".$ts);
+ try {
+ $date = new DateTime("@".$ts);
+ }
+ catch (Exception $e) {
+ return 'unknown';
+ }
- // convert to the right timezone
- $stz = date_default_timezone_get();
- $tz = new DateTimeZone($convert ? $RCMAIL->config->get('timezone') : 'GMT');
- date_default_timezone_set($tz->getName());
- $date->setTimezone($tz);
+ try {
+ // convert to the right timezone
+ $stz = date_default_timezone_get();
+ $tz = new DateTimeZone($convert ? $RCMAIL->config->get('timezones') : 'GMT');
+ $date->setTimezone($tz);
+ date_default_timezone_set($tz->getName());
- $timestamp = $date->format('U');
+ $timestamp = $date->format('U');
+ }
+ catch (Exception $e) {
+ $timestamp = $ts;
+ }
// define date format depending on current time
if (!$format) {