Function: appt-convert-time

appt-convert-time is a byte-compiled function defined in appt.el.gz.

Signature

(appt-convert-time TIME2CONV)

Documentation

Convert hour:min[am/pm] format TIME2CONV to minutes from midnight.

A period (.) can be used instead of a colon (:) to separate the hour and minute parts.

Source Code

;; Defined in /usr/src/emacs/lisp/calendar/appt.el.gz
(defun appt-convert-time (time2conv)
  "Convert hour:min[am/pm] format TIME2CONV 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)))