Changeset 4439 in subversion for trunk/roundcubemail/program/include/main.inc
- Timestamp:
- Jan 21, 2011 11:50:07 AM (2 years ago)
- File:
-
- 1 edited
-
trunk/roundcubemail/program/include/main.inc (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/roundcubemail/program/include/main.inc
r4424 r4439 979 979 980 980 /** 981 * Improved equivalent to strtotime() 982 * 983 * @param string Date string 984 * @return int 985 */ 986 function rcube_strtotime($date) 987 { 988 // check for MS Outlook vCard date format YYYYMMDD 989 if (preg_match('/^([12][90]\d\d)([01]\d)(\d\d)$/', trim($date), $matches)) { 990 return mktime(0,0,0, intval($matches[2]), intval($matches[3]), intval($matches[1])); 991 } 992 else if (is_numeric($date)) 993 return $date; 994 995 // support non-standard "GMTXXXX" literal 996 $date = preg_replace('/GMT\s*([+-][0-9]+)/', '\\1', $date); 997 998 // if date parsing fails, we have a date in non-rfc format. 999 // remove token from the end and try again 1000 while ((($ts = @strtotime($date)) === false) || ($ts < 0)) { 1001 $d = explode(' ', $date); 1002 array_pop($d); 1003 if (!$d) break; 1004 $date = implode(' ', $d); 1005 } 1006 1007 return $ts; 1008 } 1009 1010 1011 /** 981 1012 * Convert the given date to a human readable form 982 1013 * This uses the date formatting properties from config … … 992 1023 $ts = NULL; 993 1024 994 if (is_numeric($date)) 995 $ts = $date; 996 else if (!empty($date)) 997 { 998 // support non-standard "GMTXXXX" literal 999 $date = preg_replace('/GMT\s*([+-][0-9]+)/', '\\1', $date); 1000 // if date parsing fails, we have a date in non-rfc format. 1001 // remove token from the end and try again 1002 while ((($ts = @strtotime($date))===false) || ($ts < 0)) 1003 { 1004 $d = explode(' ', $date); 1005 array_pop($d); 1006 if (!$d) break; 1007 $date = implode(' ', $d); 1008 } 1009 } 1025 if (!empty($date)) 1026 $ts = rcube_strtotime($date); 1010 1027 1011 1028 if (empty($ts))
Note: See TracChangeset
for help on using the changeset viewer.
