comparison lisp/calendar/diary-lib.el @ 34036:c2a8edb5b5ec

(diary-entry-time): Anchor pattern correctly and skip whitespace and newlines.
author Gerd Moellmann <gerd@gnu.org>
date Thu, 30 Nov 2000 12:27:36 +0000
parents 82747626b78b
children 38b437f4134e
comparison
equal deleted inserted replaced
34035:e557e0e621a5 34036:c2a8edb5b5ec
975 -9999) if no time is recognized. The recognized forms are XXXX, X:XX, or 975 -9999) if no time is recognized. The recognized forms are XXXX, X:XX, or
976 XX:XX (military time), and XXam, XXAM, XXpm, XXPM, XX:XXam, XX:XXAM XX:XXpm, 976 XX:XX (military time), and XXam, XXAM, XXpm, XXPM, XX:XXam, XX:XXAM XX:XXpm,
977 or XX:XXPM." 977 or XX:XXPM."
978 (let ((case-fold-search nil)) 978 (let ((case-fold-search nil))
979 (cond ((string-match;; Military time 979 (cond ((string-match;; Military time
980 "^[ \t]*\\([0-9]?[0-9]\\):?\\([0-9][0-9]\\)\\(\\>\\|[^ap]\\)" s) 980 "\\`[ \t\n\\^M]*\\([0-9]?[0-9]\\):?\\([0-9][0-9]\\)\\(\\>\\|[^ap]\\)" s)
981 (+ (* 100 (string-to-int 981 (+ (* 100 (string-to-int
982 (substring s (match-beginning 1) (match-end 1)))) 982 (substring s (match-beginning 1) (match-end 1))))
983 (string-to-int (substring s (match-beginning 2) (match-end 2))))) 983 (string-to-int (substring s (match-beginning 2) (match-end 2)))))
984 ((string-match;; Hour only XXam or XXpm 984 ((string-match;; Hour only XXam or XXpm
985 "^[ \t]*\\([0-9]?[0-9]\\)\\([ap]\\)m\\>" s) 985 "\\`[ \t\n\\^M]*\\([0-9]?[0-9]\\)\\([ap]\\)m\\>" s)
986 (+ (* 100 (% (string-to-int 986 (+ (* 100 (% (string-to-int
987 (substring s (match-beginning 1) (match-end 1))) 987 (substring s (match-beginning 1) (match-end 1)))
988 12)) 988 12))
989 (if (equal ?a (downcase (aref s (match-beginning 2)))) 989 (if (equal ?a (downcase (aref s (match-beginning 2))))
990 0 1200))) 990 0 1200)))
991 ((string-match;; Hour and minute XX:XXam or XX:XXpm 991 ((string-match;; Hour and minute XX:XXam or XX:XXpm
992 "^[ \t]*\\([0-9]?[0-9]\\):\\([0-9][0-9]\\)\\([ap]\\)m\\>" s) 992 "\\`[ \t\n\\^M]*\\([0-9]?[0-9]\\):\\([0-9][0-9]\\)\\([ap]\\)m\\>" s)
993 (+ (* 100 (% (string-to-int 993 (+ (* 100 (% (string-to-int
994 (substring s (match-beginning 1) (match-end 1))) 994 (substring s (match-beginning 1) (match-end 1)))
995 12)) 995 12))
996 (string-to-int (substring s (match-beginning 2) (match-end 2))) 996 (string-to-int (substring s (match-beginning 2) (match-end 2)))
997 (if (equal ?a (downcase (aref s (match-beginning 3)))) 997 (if (equal ?a (downcase (aref s (match-beginning 3))))
998 0 1200))) 998 0 1200)))
999 (t diary-unknown-time))));; Unrecognizable 999 (t diary-unknown-time))));; Unrecognizable
1000
1001 ;; Unrecognizable
1000 1002
1001 (defun list-sexp-diary-entries (date) 1003 (defun list-sexp-diary-entries (date)
1002 "Add sexp entries for DATE from the diary file to `diary-entries-list'. 1004 "Add sexp entries for DATE from the diary file to `diary-entries-list'.
1003 Also, Make them visible in the diary file. Returns t if any entries were 1005 Also, Make them visible in the diary file. Returns t if any entries were
1004 found. 1006 found.