aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Morris2008-04-01 02:55:03 +0000
committerGlenn Morris2008-04-01 02:55:03 +0000
commitb3103ae991b87006c43d4b47f5986aa841ac9f94 (patch)
tree754ede8a658d138be2fc36853fb8957305edd449
parent589117b4df8fd6f6bf81fd840bab0a3374437fb0 (diff)
downloademacs-b3103ae991b87006c43d4b47f5986aa841ac9f94.tar.gz
emacs-b3103ae991b87006c43d4b47f5986aa841ac9f94.zip
(calendar-nongregorian-visible-p): New function.
-rw-r--r--lisp/calendar/calendar.el39
1 files changed, 39 insertions, 0 deletions
diff --git a/lisp/calendar/calendar.el b/lisp/calendar/calendar.el
index d4fb02309e6..61b65130864 100644
--- a/lisp/calendar/calendar.el
+++ b/lisp/calendar/calendar.el
@@ -2322,6 +2322,45 @@ interpreted as BC; -1 being 1 BC, and so on."
2322 (extract-calendar-month date) (extract-calendar-year date))) 2322 (extract-calendar-month date) (extract-calendar-year date)))
2323 2))) 2323 2)))
2324 2324
2325(defun calendar-nongregorian-visible-p (month day toabs fromabs switch)
2326 "Return non-nil if MONTH, DAY is visible in the calendar window.
2327MONTH and DAY are in some non-Gregorian calendar system. The
2328functions TOABS and FROMABS convert that system to and from
2329absolute, respectively. SWITCH is a function that takes a single
2330argument (a local month number). It applies when the local year
2331changes across the calendar window, and returns non-nil if the
2332specified month should be associated with the higher year.
2333Returns the corresponding Gregorian date."
2334 ;; We need to choose the local year associated with month and day
2335 ;; that might make them visible.
2336 (let* ((m1 displayed-month)
2337 (y1 displayed-year)
2338 (m2 displayed-month)
2339 (y2 displayed-year)
2340 ;; Absolute date of first/last dates in calendar window.
2341 (start-date (progn
2342 (increment-calendar-month m1 y1 -1)
2343 (calendar-absolute-from-gregorian (list m1 1 y1))))
2344 (end-date (progn
2345 (increment-calendar-month m2 y2 1)
2346 (calendar-absolute-from-gregorian
2347 (list m2 (calendar-last-day-of-month m2 y2) y2))))
2348 ;; Local date of first/last date in calendar window.
2349 (local-start (funcall fromabs start-date))
2350 (local-end (funcall fromabs end-date))
2351 ;; Local year of first/last dates.
2352 ;; Can only differ if displayed-month = 12, 1, 2.
2353 (local-y1 (extract-calendar-year local-start))
2354 (local-y2 (extract-calendar-year local-end))
2355 ;; Choose which year might be visible in the window.
2356 ;; Obviously it only matters when y1 and y2 differ, ie
2357 ;; when the _local_ new year is visible.
2358 (year (if (funcall switch month) local-y2 local-y1))
2359 (date (calendar-gregorian-from-absolute
2360 (funcall toabs (list month day year)))))
2361 (if (calendar-date-is-visible-p date)
2362 date)))
2363
2325(defun calendar-date-is-valid-p (date) 2364(defun calendar-date-is-valid-p (date)
2326 "Return t if DATE is a valid date." 2365 "Return t if DATE is a valid date."
2327 (let ((month (extract-calendar-month date)) 2366 (let ((month (extract-calendar-month date))