emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] Changes to emacs/lisp/calendar/calendar.el,v


From: Glenn Morris
Subject: [Emacs-diffs] Changes to emacs/lisp/calendar/calendar.el,v
Date: Tue, 01 Apr 2008 02:55:03 +0000

CVSROOT:        /sources/emacs
Module name:    emacs
Changes by:     Glenn Morris <gm>       08/04/01 02:55:03

Index: calendar.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/calendar/calendar.el,v
retrieving revision 1.237
retrieving revision 1.238
diff -u -b -r1.237 -r1.238
--- calendar.el 1 Apr 2008 02:46:29 -0000       1.237
+++ calendar.el 1 Apr 2008 02:55:03 -0000       1.238
@@ -2322,6 +2322,45 @@
                 (extract-calendar-month date) (extract-calendar-year date)))
           2)))
 
+(defun calendar-nongregorian-visible-p (month day toabs fromabs switch)
+  "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.  SWITCH is a function that takes a single
+argument (a local month number).  It applies when the local year
+changes across the calendar window, and returns non-nil if the
+specified month should be associated with the higher year.
+Returns the corresponding Gregorian date."
+  ;; We need to choose the local year associated with month and day
+  ;; that might make them visible.
+  (let* ((m1 displayed-month)
+         (y1 displayed-year)
+         (m2 displayed-month)
+         (y2 displayed-year)
+         ;; Absolute date of first/last dates in calendar window.
+         (start-date (progn
+                       (increment-calendar-month m1 y1 -1)
+                       (calendar-absolute-from-gregorian (list m1 1 y1))))
+         (end-date (progn
+                     (increment-calendar-month m2 y2 1)
+                     (calendar-absolute-from-gregorian
+                      (list m2 (calendar-last-day-of-month m2 y2) y2))))
+         ;; Local date of first/last date in calendar window.
+         (local-start (funcall fromabs start-date))
+         (local-end (funcall fromabs end-date))
+         ;; Local year of first/last dates.
+         ;; Can only differ if displayed-month = 12, 1, 2.
+         (local-y1 (extract-calendar-year local-start))
+         (local-y2 (extract-calendar-year local-end))
+         ;; Choose which year might be visible in the window.
+         ;; Obviously it only matters when y1 and y2 differ, ie
+         ;; when the _local_ new year is visible.
+         (year (if (funcall switch month) local-y2 local-y1))
+         (date (calendar-gregorian-from-absolute
+                (funcall toabs (list month day year)))))
+    (if (calendar-date-is-visible-p date)
+        date)))
+
 (defun calendar-date-is-valid-p (date)
   "Return t if DATE is a valid date."
   (let ((month (extract-calendar-month date))




reply via email to

[Prev in Thread] Current Thread [Next in Thread]