[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] Changes to emacs/lisp/calendar/appt.el
From: |
Stefan Monnier |
Subject: |
[Emacs-diffs] Changes to emacs/lisp/calendar/appt.el |
Date: |
Tue, 04 Oct 2005 16:50:40 -0400 |
Index: emacs/lisp/calendar/appt.el
diff -c emacs/lisp/calendar/appt.el:1.61 emacs/lisp/calendar/appt.el:1.62
*** emacs/lisp/calendar/appt.el:1.61 Mon Jul 4 17:37:02 2005
--- emacs/lisp/calendar/appt.el Tue Oct 4 20:50:40 2005
***************
*** 195,201 ****
FLAG, if non-nil, says that the element was made with `appt-add'
so calling `appt-make-list' again should preserve it.")
! (defconst appt-max-time 1439
"11:59pm in minutes - number of minutes in a day minus 1.")
(defvar appt-mode-string nil
--- 195,201 ----
FLAG, if non-nil, says that the element was made with `appt-add'
so calling `appt-make-list' again should preserve it.")
! (defconst appt-max-time (1- (* 24 60))
"11:59pm in minutes - number of minutes in a day minus 1.")
(defvar appt-mode-string nil
***************
*** 484,496 ****
lowest-window w)))))
(select-window lowest-window)))
;;;###autoload
(defun appt-add (new-appt-time new-appt-msg)
"Add an appointment for today at NEW-APPT-TIME with message NEW-APPT-MSG.
The time should be in either 24 hour format or am/pm format."
(interactive "sTime (hh:mm[am/pm]): \nsMessage: ")
! (unless (string-match "[0-9]?[0-9][:.][0-9][0-9]\\(am\\|pm\\)?"
! new-appt-time)
(error "Unacceptable time-string"))
(let* ((appt-time-string (concat new-appt-time " " new-appt-msg))
(appt-time (list (appt-convert-time new-appt-time)))
--- 484,498 ----
lowest-window w)))))
(select-window lowest-window)))
+ (defconst appt-time-regexp
+ "[0-9]?[0-9]\\(h\\([0-9][0-9]\\)?\\|[:.][0-9][0-9]\\)\\(am\\|pm\\)?")
+
;;;###autoload
(defun appt-add (new-appt-time new-appt-msg)
"Add an appointment for today at NEW-APPT-TIME with message NEW-APPT-MSG.
The time should be in either 24 hour format or am/pm format."
(interactive "sTime (hh:mm[am/pm]): \nsMessage: ")
! (unless (string-match appt-time-regexp new-appt-time)
(error "Unacceptable time-string"))
(let* ((appt-time-string (concat new-appt-time " " new-appt-msg))
(appt-time (list (appt-convert-time new-appt-time)))
***************
*** 577,592 ****
(calendar-date-equal
(calendar-current-date) (car (car entry-list))))
(let ((time-string (cadr (car entry-list))))
! (while (string-match
! "\\([0-9]?[0-9][:.][0-9][0-9]\\(am\\|pm\\)?\\).*"
! time-string)
(let* ((beg (match-beginning 0))
;; Get just the time for this appointment.
! (only-time (match-string 1 time-string))
;; Find the end of this appointment
;; (the start of the next).
(end (string-match
! "^[
\t]*[0-9]?[0-9][:.][0-9][0-9]\\(am\\|pm\\)?"
time-string
(match-end 0)))
;; Get the whole string for this appointment.
--- 579,592 ----
(calendar-date-equal
(calendar-current-date) (car (car entry-list))))
(let ((time-string (cadr (car entry-list))))
! (while (string-match appt-time-regexp time-string)
(let* ((beg (match-beginning 0))
;; Get just the time for this appointment.
! (only-time (match-string 0 time-string))
;; Find the end of this appointment
;; (the start of the next).
(end (string-match
! (concat "\n[ \t]*" appt-time-regexp)
time-string
(match-end 0)))
;; Get the whole string for this appointment.
***************
*** 633,663 ****
"Convert hour:min[am/pm] format to minutes from midnight.
A period (.) can be used instead of a colon (:) to separate the
hour and minute parts."
! (let ((conv-time 0)
! (hr 0)
! (min 0))
!
! (string-match "[:.]\\([0-9][0-9]\\)" time2conv)
! (setq min (string-to-number
! (match-string 1 time2conv)))
!
! (string-match "[0-9]?[0-9][:.]" time2conv)
! (setq hr (string-to-number
! (match-string 0 time2conv)))
;; convert the time appointment time into 24 hour time
-
(cond ((and (string-match "pm" time2conv) (< hr 12))
(setq hr (+ 12 hr)))
((and (string-match "am" time2conv) (= hr 12))
(setq hr 0)))
! ;; convert the actual time
! ;; into minutes for comparison
! ;; against the actual time.
!
! (setq conv-time (+ (* hr 60) min))
! conv-time))
(defun appt-update-list ()
--- 633,655 ----
"Convert hour:min[am/pm] format to minutes from midnight.
A period (.) can be used instead of a colon (:) to separate the
hour and minute parts."
! ;; Formats that should be accepted:
! ;; 10:00 10.00 10h00 10h 10am 10:00am 10.00am
! (let ((min (if (string-match "[h:.]\\([0-9][0-9]\\)" time2conv)
! (string-to-number (match-string 1 time2conv))
! 0))
! (hr (if (string-match "[0-9]*[0-9]" time2conv)
! (string-to-number (match-string 0 time2conv))
! 0)))
;; convert the time appointment time into 24 hour time
(cond ((and (string-match "pm" time2conv) (< hr 12))
(setq hr (+ 12 hr)))
((and (string-match "am" time2conv) (= hr 12))
(setq hr 0)))
! ;; convert the actual time into minutes.
! (+ (* hr 60) min)))
(defun appt-update-list ()
***************
*** 719,723 ****
(provide 'appt)
! ;;; arch-tag: bf5791c4-8921-499e-a26f-772b1788d347
;;; appt.el ends here
--- 711,715 ----
(provide 'appt)
! ;; arch-tag: bf5791c4-8921-499e-a26f-772b1788d347
;;; appt.el ends here
- [Emacs-diffs] Changes to emacs/lisp/calendar/appt.el,
Stefan Monnier <=