Function: calendar-date-is-valid-p

calendar-date-is-valid-p is a byte-compiled function defined in calendar.el.gz.

Signature

(calendar-date-is-valid-p DATE)

Documentation

Return t if DATE is a valid date.

Source Code

;; Defined in /usr/src/emacs/lisp/calendar/calendar.el.gz
(defun calendar-date-is-valid-p (date)
  "Return t if DATE is a valid date."
  (when (and (listp date)
             (length= date 3))
    (let ((month (calendar-extract-month date))
          (day (calendar-extract-day date))
          (year (calendar-extract-year date)))
      (and (integerp month) (integerp day) (integerp year)
           (<= 1 month) (<= month 12)
           ;; (calendar-read-date t) used to return a date with day = nil.
           ;; Should not be valid (?), since many funcs prob assume integer.
           ;; (calendar-read-date 'noday) returns (month year), which
           ;; currently results in calendar-extract-year returning nil.
           day year (<= 1 day) (<= day (calendar-last-day-of-month month year))
           ;; BC dates left as non-valid, to suppress errors from
           ;; complex holiday algorithms not suitable for years BC.
           ;; Note there are side effects on calendar navigation.
           (<= 1 year)))))