# HG changeset patch # User Edward M. Reingold # Date 814747103 0 # Node ID 77d8e407592e56414375cd0998e6768a4b03d65f # Parent 63a43c4b29b21142000c2250e5d42c2028515848 Fix the way the sexagisimal names are calculated. diff -r 63a43c4b29b2 -r 77d8e407592e lisp/calendar/cal-china.el --- a/lisp/calendar/cal-china.el Thu Oct 26 19:06:38 1995 +0000 +++ b/lisp/calendar/cal-china.el Thu Oct 26 22:38:23 1995 +0000 @@ -319,12 +319,10 @@ (calendar-gregorian-from-absolute (cdr (assoc 1 (chinese-year y)))))) (if (calendar-date-is-visible-p chinese-new-year) - (list (list chinese-new-year - (format "Chinese New Year (%s-%s)" - (aref chinese-calendar-celestial-stem - (% (+ y 6) 10)) - (aref chinese-calendar-terrestrial-branch - (% (+ y 8) 12)))))))))) + (list + (list chinese-new-year + (format "Chinese New Year (%s)" + (calendar-chinese-sexagisimal-name (+ y 57)))))))))) (defun calendar-chinese-date-string (&optional date) "String of Chinese date of Gregorian DATE. @@ -344,20 +342,28 @@ (calendar-mod (1+ (floor month)) 12) 1))) (m-cycle (% (+ (* year 5) (floor month)) 60))) - (format "Cycle %s, year %s (%s-%s), %smonth %s, day %s (%s-%s)" + (format "Cycle %s, year %s (%s), %smonth %s%s, day %s (%s)" cycle - year - (aref chinese-calendar-celestial-stem (% (+ year 9) 10)) - (aref chinese-calendar-terrestrial-branch (% (+ year 11) 12)) + year (calendar-chinese-sexagisimal-name year) (if (not (integerp month)) "second " (if (< 30 (- next-month this-month)) "first " "")) (floor month) - day - (aref chinese-calendar-celestial-stem (% (+ a-date 4) 10)) - (aref chinese-calendar-terrestrial-branch (% (+ a-date 2) 12))))) + (if (integerp month) + (format " (%s)" (calendar-chinese-sexagisimal-name + (+ (* 5 year) month 44))) + "") + day (calendar-chinese-sexagisimal-name (+ a-date 15))))) + +(defun calendar-chinese-sexagisimal-name (n) + "The N-th name of the Chinese sexagisimal cycle. +N congruent to 1 gives the first name, N congruent to 2 gives the second name, +..., N congruent to 60 gives the sixtieth name." + (format "%s-%s" + (aref chinese-calendar-celestial-stem (% (1- n) 10)) + (aref chinese-calendar-terrestrial-branch (% (1- n) 12)))) (defun calendar-print-chinese-date () "Show the Chinese date equivalents of date."