Changeset 87986cf in github


Ignore:
Timestamp:
Jan 6, 2012 4:40:32 AM (17 months ago)
Author:
thomascube <thomas@…>
Branches:
master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.8
Children:
529bd3f
Parents:
ac78df3
Message:

Handle DateTime? exceptions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • program/include/main.inc

    rac78df3 r87986cf  
    10631063    return ''; 
    10641064 
    1065   $date = new DateTime("@".$ts); 
    1066  
    1067   // convert to the right timezone 
    1068   $stz = date_default_timezone_get(); 
    1069   $tz = new DateTimeZone($convert ? $RCMAIL->config->get('timezone') : 'GMT'); 
    1070   date_default_timezone_set($tz->getName()); 
    1071   $date->setTimezone($tz); 
    1072  
    1073   $timestamp = $date->format('U'); 
     1065  try { 
     1066    $date = new DateTime("@".$ts); 
     1067  } 
     1068  catch (Exception $e) { 
     1069    return 'unknown'; 
     1070  } 
     1071 
     1072  try { 
     1073    // convert to the right timezone 
     1074    $stz = date_default_timezone_get(); 
     1075    $tz = new DateTimeZone($convert ? $RCMAIL->config->get('timezones') : 'GMT'); 
     1076    $date->setTimezone($tz); 
     1077    date_default_timezone_set($tz->getName()); 
     1078 
     1079    $timestamp = $date->format('U'); 
     1080  } 
     1081  catch (Exception $e) { 
     1082    $timestamp = $ts; 
     1083  } 
    10741084 
    10751085  // define date format depending on current time 
Note: See TracChangeset for help on using the changeset viewer.