Changeset 3127847 in github
- Timestamp:
- Jan 21, 2011 11:50:07 AM (2 years ago)
- Branches:
- master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.6, release-0.7, release-0.8
- Children:
- 26e76df
- Parents:
- 58b5dde
- Location:
- program/include
- Files:
-
- 2 edited
-
main.inc (modified) (2 diffs)
-
rcube_imap_generic.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
program/include/main.inc
r0501b63 r3127847 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)) -
program/include/rcube_imap_generic.php
rf5e7b353 r3127847 3224 3224 private function strToTime($date) 3225 3225 { 3226 // support non-standard "GMTXXXX" literal 3227 $date = preg_replace('/GMT\s*([+-][0-9]+)/', '\\1', $date); 3228 // if date parsing fails, we have a date in non-rfc format. 3229 // remove token from the end and try again 3230 while ((($ts = @strtotime($date))===false) || ($ts < 0)) { 3231 $d = explode(' ', $date); 3232 array_pop($d); 3233 if (!$d) { 3234 break; 3235 } 3236 $date = implode(' ', $d); 3237 } 3238 3239 $ts = (int) $ts; 3240 3226 $ts = (int) rcube_strtotime($date); 3241 3227 return $ts < 0 ? 0 : $ts; 3242 3228 }
Note: See TracChangeset
for help on using the changeset viewer.
