changeset 93453:22b3710e206a

(holiday-chinese-new-year): Doc fix and comment.
author Glenn Morris <rgm@gnu.org>
date Mon, 31 Mar 2008 07:40:11 +0000
parents 3a405950a311
children 648b1e67e4b5
files lisp/calendar/cal-china.el
diffstat 1 files changed, 12 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/calendar/cal-china.el	Mon Mar 31 07:18:59 2008 +0000
+++ b/lisp/calendar/cal-china.el	Mon Mar 31 07:40:11 2008 +0000
@@ -421,19 +421,25 @@
 
 ;;;###holiday-autoload
 (defun holiday-chinese-new-year ()
-  "Date of Chinese New Year."
+  "Date of Chinese New Year, if visible in calendar.
+Returns (((MONTH DAY YEAR) TEXT)), where the date is Gregorian."
   (let ((m displayed-month)
         (y displayed-year))
-    (increment-calendar-month m y 1)
+    ;; In the Gregorian calendar, CNY falls between Jan 21 and Feb 20.
+    ;; Jan is visible if displayed-month = 12, 1, 2; Feb if d-m = 1, 2, 3.
+    ;; If we shift the calendar forward one month, we can do a
+    ;; one-sided test, namely: d-m <= 4 means CNYN might be visible.
+    (increment-calendar-month m y 1)    ; shift forward a month
     (if (< m 5)
         (let ((chinese-new-year
                (calendar-gregorian-from-absolute
                 (cadr (assoc 1 (chinese-year y))))))
           (if (calendar-date-is-visible-p chinese-new-year)
-          (list
-           (list chinese-new-year
-                 (format "Chinese New Year (%s)"
-                         (calendar-chinese-sexagesimal-name (+ y 57))))))))))
+              (list
+               (list chinese-new-year
+                     (format "Chinese New Year (%s)"
+                             (calendar-chinese-sexagesimal-name
+                              (+ y 57))))))))))
 
 ;;;###cal-autoload
 (defun calendar-chinese-date-string (&optional date)