195 |
FLAG, if non-nil, says that the element was made with `appt-add' |
FLAG, if non-nil, says that the element was made with `appt-add' |
196 |
so calling `appt-make-list' again should preserve it.") |
so calling `appt-make-list' again should preserve it.") |
197 |
|
|
198 |
(defconst appt-max-time 1439 |
(defconst appt-max-time (1- (* 24 60)) |
199 |
"11:59pm in minutes - number of minutes in a day minus 1.") |
"11:59pm in minutes - number of minutes in a day minus 1.") |
200 |
|
|
201 |
(defvar appt-mode-string nil |
(defvar appt-mode-string nil |
484 |
lowest-window w))))) |
lowest-window w))))) |
485 |
(select-window lowest-window))) |
(select-window lowest-window))) |
486 |
|
|
487 |
|
(defconst appt-time-regexp |
488 |
|
"[0-9]?[0-9]\\(h\\([0-9][0-9]\\)?\\|[:.][0-9][0-9]\\)\\(am\\|pm\\)?") |
489 |
|
|
490 |
;;;###autoload |
;;;###autoload |
491 |
(defun appt-add (new-appt-time new-appt-msg) |
(defun appt-add (new-appt-time new-appt-msg) |
492 |
"Add an appointment for today at NEW-APPT-TIME with message NEW-APPT-MSG. |
"Add an appointment for today at NEW-APPT-TIME with message NEW-APPT-MSG. |
493 |
The time should be in either 24 hour format or am/pm format." |
The time should be in either 24 hour format or am/pm format." |
494 |
(interactive "sTime (hh:mm[am/pm]): \nsMessage: ") |
(interactive "sTime (hh:mm[am/pm]): \nsMessage: ") |
495 |
(unless (string-match "[0-9]?[0-9][:.][0-9][0-9]\\(am\\|pm\\)?" |
(unless (string-match appt-time-regexp new-appt-time) |
|
new-appt-time) |
|
496 |
(error "Unacceptable time-string")) |
(error "Unacceptable time-string")) |
497 |
(let* ((appt-time-string (concat new-appt-time " " new-appt-msg)) |
(let* ((appt-time-string (concat new-appt-time " " new-appt-msg)) |
498 |
(appt-time (list (appt-convert-time new-appt-time))) |
(appt-time (list (appt-convert-time new-appt-time))) |
579 |
(calendar-date-equal |
(calendar-date-equal |
580 |
(calendar-current-date) (car (car entry-list)))) |
(calendar-current-date) (car (car entry-list)))) |
581 |
(let ((time-string (cadr (car entry-list)))) |
(let ((time-string (cadr (car entry-list)))) |
582 |
(while (string-match |
(while (string-match appt-time-regexp time-string) |
|
"\\([0-9]?[0-9][:.][0-9][0-9]\\(am\\|pm\\)?\\).*" |
|
|
time-string) |
|
583 |
(let* ((beg (match-beginning 0)) |
(let* ((beg (match-beginning 0)) |
584 |
;; Get just the time for this appointment. |
;; Get just the time for this appointment. |
585 |
(only-time (match-string 1 time-string)) |
(only-time (match-string 0 time-string)) |
586 |
;; Find the end of this appointment |
;; Find the end of this appointment |
587 |
;; (the start of the next). |
;; (the start of the next). |
588 |
(end (string-match |
(end (string-match |
589 |
"^[ \t]*[0-9]?[0-9][:.][0-9][0-9]\\(am\\|pm\\)?" |
(concat "\n[ \t]*" appt-time-regexp) |
590 |
time-string |
time-string |
591 |
(match-end 0))) |
(match-end 0))) |
592 |
;; Get the whole string for this appointment. |
;; Get the whole string for this appointment. |
633 |
"Convert hour:min[am/pm] format to minutes from midnight. |
"Convert hour:min[am/pm] format to minutes from midnight. |
634 |
A period (.) can be used instead of a colon (:) to separate the |
A period (.) can be used instead of a colon (:) to separate the |
635 |
hour and minute parts." |
hour and minute parts." |
636 |
(let ((conv-time 0) |
;; Formats that should be accepted: |
637 |
(hr 0) |
;; 10:00 10.00 10h00 10h 10am 10:00am 10.00am |
638 |
(min 0)) |
(let ((min (if (string-match "[h:.]\\([0-9][0-9]\\)" time2conv) |
639 |
|
(string-to-number (match-string 1 time2conv)) |
640 |
(string-match "[:.]\\([0-9][0-9]\\)" time2conv) |
0)) |
641 |
(setq min (string-to-number |
(hr (if (string-match "[0-9]*[0-9]" time2conv) |
642 |
(match-string 1 time2conv))) |
(string-to-number (match-string 0 time2conv)) |
643 |
|
0))) |
|
(string-match "[0-9]?[0-9][:.]" time2conv) |
|
|
(setq hr (string-to-number |
|
|
(match-string 0 time2conv))) |
|
644 |
|
|
645 |
;; convert the time appointment time into 24 hour time |
;; convert the time appointment time into 24 hour time |
|
|
|
646 |
(cond ((and (string-match "pm" time2conv) (< hr 12)) |
(cond ((and (string-match "pm" time2conv) (< hr 12)) |
647 |
(setq hr (+ 12 hr))) |
(setq hr (+ 12 hr))) |
648 |
((and (string-match "am" time2conv) (= hr 12)) |
((and (string-match "am" time2conv) (= hr 12)) |
649 |
(setq hr 0))) |
(setq hr 0))) |
650 |
|
|
651 |
;; convert the actual time |
;; convert the actual time into minutes. |
652 |
;; into minutes for comparison |
(+ (* hr 60) min))) |
|
;; against the actual time. |
|
|
|
|
|
(setq conv-time (+ (* hr 60) min)) |
|
|
conv-time)) |
|
653 |
|
|
654 |
|
|
655 |
(defun appt-update-list () |
(defun appt-update-list () |
711 |
|
|
712 |
(provide 'appt) |
(provide 'appt) |
713 |
|
|
714 |
;;; arch-tag: bf5791c4-8921-499e-a26f-772b1788d347 |
;; arch-tag: bf5791c4-8921-499e-a26f-772b1788d347 |
715 |
;;; appt.el ends here |
;;; appt.el ends here |