]> code.delx.au - gnu-emacs/blobdiff - lisp/timezone.el
Customize.
[gnu-emacs] / lisp / timezone.el
index c26adf78702bc8c8e1696aad0e2259583dbdf8e8..949a7f12dc281c6f4051eb0339aa68fefefcb3f1 100644 (file)
@@ -145,6 +145,16 @@ Understands the following styles:
        (time nil)
        (zone nil))                     ;This may be nil.
     (cond ((string-match
+           "\\([0-9]+\\)[ \t]+\\([^ \t,]+\\)[ \t]+\\([0-9]+\\)[ \t]+\\([0-9]+:[0-9:]+\\)[ \t]*\\([-+a-zA-Z0-9]+\\)" date)
+          ;; Styles: (1) and (2) with timezone and buggy timezone
+          ;; This is most common in mail and news,
+          ;; so it is worth trying first.
+          (setq year 3 month 2 day 1 time 4 zone 5))
+         ((string-match
+           "\\([0-9]+\\)[ \t]+\\([^ \t,]+\\)[ \t]+\\([0-9]+\\)[ \t]+\\([0-9]+:[0-9:]+\\)[ \t]*\\'" date)
+          ;; Styles: (1) and (2) without timezone
+          (setq year 3 month 2 day 1 time 4 zone nil))
+         ((string-match
            "\\([^ \t,]+\\),[ \t]+\\([0-9]+\\)[ \t]+\\([^ \t,]+\\)[ \t]+\\([0-9]+:[0-9:]+\\)[ \t]+\\(T[ \t]+\\|\\)\\([0-9]+\\)[ \t]*\\'" date)
           ;; Styles: (6) and (7) without timezone
           (setq year 6 month 3 day 2 time 4 zone nil))
@@ -152,14 +162,6 @@ Understands the following styles:
            "\\([^ \t,]+\\),[ \t]+\\([0-9]+\\)[ \t]+\\([^ \t,]+\\)[ \t]+\\([0-9]+:[0-9:]+\\)[ \t]+\\(T[ \t]+\\|\\)\\([0-9]+\\)[ \t]*\\([-+a-zA-Z0-9]+\\)" date)
           ;; Styles: (6) and (7) with timezone and buggy timezone
           (setq year 6 month 3 day 2 time 4 zone 7))
-         ((string-match
-           "\\([0-9]+\\)[ \t]+\\([^ \t,]+\\)[ \t]+\\([0-9]+\\)[ \t]+\\([0-9]+:[0-9:]+\\)[ \t]*\\'" date)
-          ;; Styles: (1) and (2) without timezone
-          (setq year 3 month 2 day 1 time 4 zone nil))
-         ((string-match
-           "\\([0-9]+\\)[ \t]+\\([^ \t,]+\\)[ \t]+\\([0-9]+\\)[ \t]+\\([0-9]+:[0-9:]+\\)[ \t]*\\([-+a-zA-Z0-9]+\\)" date)
-          ;; Styles: (1) and (2) with timezone and buggy timezone
-          (setq year 3 month 2 day 1 time 4 zone 5))
          ((string-match
            "\\([^ \t,]+\\)[ \t]+\\([0-9]+\\)[ \t]+\\([0-9]+:[0-9:]+\\)[ \t]+\\([0-9]+\\)" date)
           ;; Styles: (3) without timezone
@@ -200,11 +202,14 @@ Understands the following styles:
                    (substring date
                               (match-beginning month)
                               (+ (match-beginning month) 2))
-                 (let ((string (substring date
-                                (match-beginning month)
-                                (+ (match-beginning month) 3))))
-                   (int-to-string
-                    (cdr (assoc (upcase string) timezone-months-assoc))))))
+                 (let* ((string (substring date
+                                           (match-beginning month)
+                                           (+ (match-beginning month) 3)))
+                        (monthnum
+                         (cdr (assoc (upcase string) timezone-months-assoc))))
+                   (if monthnum
+                       (int-to-string monthnum)
+                     nil))))
          (setq day
                (substring date (match-beginning day) (match-end day)))
          (setq time
@@ -213,7 +218,7 @@ Understands the following styles:
        (setq zone
              (substring date (match-beginning zone) (match-end zone))))
     ;; Return a vector.
-    (if year
+    (if (and year month)
        (vector year month day time zone)
       (vector "0" "0" "0" "0" nil))
     ))