summaryrefslogtreecommitdiff
path: root/program
diff options
context:
space:
mode:
authorAleksander Machniak <alec@alec.pl>2013-08-24 18:08:54 +0200
committerAleksander Machniak <alec@alec.pl>2013-08-24 18:08:54 +0200
commitb32fab16efb715568f54781bcc9e14e30ce41bff (patch)
treeb3100876482e70d7cd865c3676f29b86df546ece /program
parent9f754494e74396469ff6ceb34ece25b088756ffa (diff)
Fix handling of non-default date formats (#1489294)
- remove ambiguous m/d/Y format from default config
Diffstat (limited to 'program')
-rw-r--r--program/lib/Roundcube/rcube_utils.php17
1 files changed, 14 insertions, 3 deletions
diff --git a/program/lib/Roundcube/rcube_utils.php b/program/lib/Roundcube/rcube_utils.php
index cf87dedb7..2540f779d 100644
--- a/program/lib/Roundcube/rcube_utils.php
+++ b/program/lib/Roundcube/rcube_utils.php
@@ -739,11 +739,22 @@ class rcube_utils
*/
public static function strtotime($date)
{
+ $date = trim($date);
+
// check for MS Outlook vCard date format YYYYMMDD
- if (preg_match('/^([12][90]\d\d)([01]\d)(\d\d)$/', trim($date), $matches)) {
- return mktime(0,0,0, intval($matches[2]), intval($matches[3]), intval($matches[1]));
+ if (preg_match('/^([12][90]\d\d)([01]\d)([0123]\d)$/', $date, $m)) {
+ return mktime(0,0,0, intval($m[2]), intval($m[3]), intval($m[1]));
}
- else if (is_numeric($date)) {
+
+ // common little-endian formats, e.g. dd/mm/yyyy (not all are supported by strtotime)
+ if (preg_match('/^(\d{1,2})[.\/-](\d{1,2})[.\/-](\d{4})$/', $date, $m)
+ && $m[1] > 0 && $m[1] <= 31 && $m[2] > 0 && $m[2] <= 12 && $m[3] >= 1970
+ ) {
+ return mktime(0,0,0, intval($m[2]), intval($m[1]), intval($m[3]));
+ }
+
+ // unix timestamp
+ if (is_numeric($date)) {
return (int) $date;
}