]> code.delx.au - gnu-emacs/blobdiff - lisp/calendar/diary-lib.el
Three insertion options:
[gnu-emacs] / lisp / calendar / diary-lib.el
index 70a03fa26d732e6046f20f08604fb74079dd7d50..e002958978ed96d7d5b43817e327bdf67f2d885f 100644 (file)
@@ -882,29 +882,28 @@ A value of 0 in any position of the pattern is a wildcard."
 For example, returns 1325 for 1:25pm.  Returns -9999 if no time is recognized.
 The recognized forms are XXXX or X:XX or XX:XX (military time), XXam or XXpm,
 and XX:XXam or XX:XXpm."
-  (cond ((string-match;; Military time  
-          "^[ \t]*\\([0-9]?[0-9]\\):?\\([0-9][0-9]\\)\\(\\>\\|[^ap]\\)" s)
-         (+ (* 100 (string-to-int
-                    (substring s (match-beginning 1) (match-end 1))))
-            (string-to-int (substring s (match-beginning 2) (match-end 2)))))
-        ((string-match;; Hour only  XXam or XXpm
-          "^[ \t]*\\([0-9]?[0-9]\\)\\([ap]\\)m\\>" s)
-         (+ (* 100 (% (string-to-int
-                         (substring s (match-beginning 1) (match-end 1)))
-                        12))
-            (if (string-equal "a"
-                              (substring s (match-beginning 2) (match-end 2)))
-                0 1200)))
-        ((string-match;; Hour and minute  XX:XXam or XX:XXpm
-          "^[ \t]*\\([0-9]?[0-9]\\):\\([0-9][0-9]\\)\\([ap]\\)m\\>" s)
-         (+ (* 100 (% (string-to-int
-                         (substring s (match-beginning 1) (match-end 1)))
-                        12))
-            (string-to-int (substring s (match-beginning 2) (match-end 2)))
-            (if (string-equal "a"
-                              (substring s (match-beginning 3) (match-end 3)))
-                0 1200)))
-        (t -9999)));; Unrecognizable
+  (let ((case-fold-search nil))
+    (cond ((string-match;; Military time  
+           "^[ \t]*\\([0-9]?[0-9]\\):?\\([0-9][0-9]\\)\\(\\>\\|[^ap]\\)" s)
+          (+ (* 100 (string-to-int
+                     (substring s (match-beginning 1) (match-end 1))))
+             (string-to-int (substring s (match-beginning 2) (match-end 2)))))
+         ((string-match;; Hour only  XXam or XXpm
+           "^[ \t]*\\([0-9]?[0-9]\\)\\([ap]\\)m\\>" s)
+          (+ (* 100 (% (string-to-int
+                          (substring s (match-beginning 1) (match-end 1)))
+                         12))
+             (if (equal ?a (downcase (aref s (match-beginning 2))))
+                 0 1200)))
+         ((string-match;; Hour and minute  XX:XXam or XX:XXpm
+           "^[ \t]*\\([0-9]?[0-9]\\):\\([0-9][0-9]\\)\\([ap]\\)m\\>" s)
+          (+ (* 100 (% (string-to-int
+                          (substring s (match-beginning 1) (match-end 1)))
+                         12))
+             (string-to-int (substring s (match-beginning 2) (match-end 2)))
+             (if (equal ?a (downcase (aref s (match-beginning 3))))
+                 0 1200)))
+         (t -9999))));; Unrecognizable
 
 (defun list-sexp-diary-entries (date)
   "Add sexp entries for DATE from the diary file to `diary-entries-list'.
@@ -1197,33 +1196,34 @@ An optional parameter DAY means the Nth DAYNAME on or after/before MONTH DAY."
               (m2 (extract-calendar-month last))
               (d2 (extract-calendar-day last))
               (y2 (extract-calendar-year last)))
-         (or (and (= m1 m2); only possible base dates in one month
-                  (or (and (listp month) (memq m1 month))
-                      (= m1 month)
-                      (eq month t))
-                  (let ((d (or day (if (> n 0)
-                                       1
-                                     (calendar-last-day-of-month m1 y1)))))
-                    (and (<= d1 day) (<= day d2))))
-             (and (< m1 m2); only possible base dates straddle two months
-                  (or
-                   ; m1, d1 works is a base date
-                   (and
-                    (or (and (listp month) (memq m1 month))
-                        (= m1 month)
-                        (eq month t))
-                    (<= d1 (or day (if (> n 0)
-                                       1
-                                     (calendar-last-day-of-month m1 y1)))))
-                   ; m2, d2 works is a base date
-                   (and (or (and (listp month) (memq m2 month))
-                            (= m2 month)
-                            (eq month t))
-                        (<= (or day (if (> n 0)
-                                        1
-                                      (calendar-last-day-of-month m2 y2)))
-                            d2)))))
-         entry)))
+        (if (or (and (= m1 m2)         ; only possible base dates in one month
+                     (or (and (listp month) (memq m1 month))
+                         (eq month t)
+                         (= m1 month))
+                     (let ((d (or day (if (> n 0)
+                                          1
+                                        (calendar-last-day-of-month m1 y1)))))
+                       (and (<= d1 d) (<= d d2))))
+                ;; only possible base dates straddle two months
+                (and (< m1 m2)
+                     (or
+                      ;; m1, d1 works is a base date
+                      (and
+                       (or (and (listp month) (memq m1 month))
+                           (eq month t)
+                           (= m1 month))
+                       (<= d1 (or day (if (> n 0)
+                                          1
+                                        (calendar-last-day-of-month m1 y1)))))
+                      ;; m2, d2 works is a base date
+                      (and (or (and (listp month) (memq m2 month))
+                               (eq month t)
+                               (= m2 month))
+                           (<= (or day (if (> n 0)
+                                           1
+                                         (calendar-last-day-of-month m2 y2)))
+                               d2)))))
+            entry))))
 
 (defun diary-anniversary (month day year)
   "Anniversary diary entry.