comparison lisp/calendar/cal-china.el @ 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 f59ab0cdc9ba
children 648b1e67e4b5
comparison
equal deleted inserted replaced
93452:3a405950a311 93453:22b3710e206a
419 (defvar displayed-month) 419 (defvar displayed-month)
420 (defvar displayed-year) 420 (defvar displayed-year)
421 421
422 ;;;###holiday-autoload 422 ;;;###holiday-autoload
423 (defun holiday-chinese-new-year () 423 (defun holiday-chinese-new-year ()
424 "Date of Chinese New Year." 424 "Date of Chinese New Year, if visible in calendar.
425 Returns (((MONTH DAY YEAR) TEXT)), where the date is Gregorian."
425 (let ((m displayed-month) 426 (let ((m displayed-month)
426 (y displayed-year)) 427 (y displayed-year))
427 (increment-calendar-month m y 1) 428 ;; In the Gregorian calendar, CNY falls between Jan 21 and Feb 20.
429 ;; Jan is visible if displayed-month = 12, 1, 2; Feb if d-m = 1, 2, 3.
430 ;; If we shift the calendar forward one month, we can do a
431 ;; one-sided test, namely: d-m <= 4 means CNYN might be visible.
432 (increment-calendar-month m y 1) ; shift forward a month
428 (if (< m 5) 433 (if (< m 5)
429 (let ((chinese-new-year 434 (let ((chinese-new-year
430 (calendar-gregorian-from-absolute 435 (calendar-gregorian-from-absolute
431 (cadr (assoc 1 (chinese-year y)))))) 436 (cadr (assoc 1 (chinese-year y))))))
432 (if (calendar-date-is-visible-p chinese-new-year) 437 (if (calendar-date-is-visible-p chinese-new-year)
433 (list 438 (list
434 (list chinese-new-year 439 (list chinese-new-year
435 (format "Chinese New Year (%s)" 440 (format "Chinese New Year (%s)"
436 (calendar-chinese-sexagesimal-name (+ y 57)))))))))) 441 (calendar-chinese-sexagesimal-name
442 (+ y 57))))))))))
437 443
438 ;;;###cal-autoload 444 ;;;###cal-autoload
439 (defun calendar-chinese-date-string (&optional date) 445 (defun calendar-chinese-date-string (&optional date)
440 "String of Chinese date of Gregorian DATE. 446 "String of Chinese date of Gregorian DATE.
441 Defaults to today's date if DATE is not given." 447 Defaults to today's date if DATE is not given."