Function: calendar-nongregorian-date-visible-p
calendar-nongregorian-date-visible-p is a byte-compiled function
defined in calendar.el.gz.
Signature
(calendar-nongregorian-date-visible-p MONTH DAY TOABS FROMABS &optional N)
Documentation
Return non-nil if MONTH, DAY is visible in the calendar window.
MONTH and DAY are in some non-Gregorian calendar system. The functions TOABS and FROMABS convert that system to and from absolute, respectively. The optional argument N is an integer indicating the first local month in the non-Gregorian local year and defaults to 1. Returns a list of corresponding Gregorian dates.
Source Code
;; Defined in /usr/src/emacs/lisp/calendar/calendar.el.gz
(defun calendar-nongregorian-date-visible-p (month day toabs fromabs &optional N)
"Return non-nil if MONTH, DAY is visible in the calendar window.
MONTH and DAY are in some non-Gregorian calendar system. The functions
TOABS and FROMABS convert that system to and from absolute,
respectively. The optional argument N is an integer indicating the
first local month in the non-Gregorian local year and defaults to 1.
Returns a list of corresponding Gregorian dates."
(let* ((range (calendar-get-date-range t))
(start-date (calendar-absolute-from-gregorian (car range)))
(end-date (calendar-absolute-from-gregorian (cdr range)))
;; Local date of first/last date in calendar window.
(local-start (funcall fromabs start-date))
(local-end (funcall fromabs end-date))
;; Local year/month of first/last dates.
(y1 (calendar-extract-year local-start))
(y2 (calendar-extract-year local-end))
(m1 (calendar-extract-month local-start))
(m2 (calendar-extract-month local-end))
(N (or N 1))
dates)
(cond
;; The local calendar:
;; Year : y1 ............. y1 y2 ............. y2
;; Month (N=1): 1 ... ..... ... END 1 ... ..... ... END
;; Month (N>1): N ... END 1 ... N-1 N ... END 1 ... N-1
((= y1 y2)
(when (or (<= m1 month m2)
;; N > 1
(and (> m1 m2)
(or (>= month m1)
(<= month m2))))
(push (list month day y1) dates)))
((< y1 y2)
;; In a large calendar range (e.g. 12 months), the same local
;; month may appear twice and there may be three local years.
;; Cf holiday-chinese.
(dotimes (i (- y2 y1 1))
(push (list month day (+ y1 i 1)) dates))
(if (>= m1 N)
(progn
(when (or (>= month m1) (< month N))
(push (list month day y1) dates))
(when (<= month m2)
(push (list month day y2) dates)))
;; m1 < N
(when (and (<= m1 month) (< month N))
(push (list month day y1) dates))
(when (or (>= month N) (<= month m2))
(push (list month day y2) dates)))))
(seq-filter 'calendar-date-is-visible-p
(mapcar (lambda (d) (calendar-gregorian-from-absolute
(funcall toabs d)))
dates))))