aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Morris2008-04-23 03:03:43 +0000
committerGlenn Morris2008-04-23 03:03:43 +0000
commit418c2f01e1900ba427e51e21c0782b3d8a0e6633 (patch)
treeb88015096de3ac9dc63b694e5527c51a71e1ba53
parent43c783b89abb1f6eff8c8490e88b3c4863a6f60b (diff)
downloademacs-418c2f01e1900ba427e51e21c0782b3d8a0e6633.tar.gz
emacs-418c2f01e1900ba427e51e21c0782b3d8a0e6633.zip
(holiday-chinese-qingming, holiday-chinese-winter-solstice)
(holiday-chinese): New functions.
-rw-r--r--lisp/calendar/cal-china.el66
1 files changed, 66 insertions, 0 deletions
diff --git a/lisp/calendar/cal-china.el b/lisp/calendar/cal-china.el
index 556c72379c5..dc3ed506d85 100644
--- a/lisp/calendar/cal-china.el
+++ b/lisp/calendar/cal-china.el
@@ -487,6 +487,72 @@ Returns (((MONTH DAY YEAR) TEXT)), where the date is Gregorian."
487 (format "Chinese New Year (%s)" 487 (format "Chinese New Year (%s)"
488 (calendar-chinese-sexagesimal-name (+ y 57)))))))) 488 (calendar-chinese-sexagesimal-name (+ y 57))))))))
489 489
490;;;###holiday-autoload
491(defun holiday-chinese-qingming ()
492 "Date of Chinese Qingming Festival, if visible in calendar.
493Returns (((MONTH DAY YEAR) TEXT)), where the date is Gregorian."
494 (when (memq displayed-month '(3 4 5)) ; is April visible?
495 (list (list (calendar-gregorian-from-absolute
496 ;; 15 days after Vernal Equinox.
497 (+ 15
498 (calendar-chinese-zodiac-sign-on-or-after
499 (calendar-absolute-from-gregorian
500 (list 3 15 displayed-year)))))
501 "Qingming Festival"))))
502
503;;;###holiday-autoload
504(defun holiday-chinese-winter-solstice ()
505 "Date of Chinese winter solstice, if visible in calendar.
506Returns (((MONTH DAY YEAR) TEXT)), where the date is Gregorian."
507 (when (memq displayed-month '(11 12 1)) ; is December visible?
508 (list (list (calendar-gregorian-from-absolute
509 (calendar-chinese-zodiac-sign-on-or-after
510 (calendar-absolute-from-gregorian
511 (list 12 15 (if (eq displayed-month 1)
512 (1- displayed-year)
513 displayed-year)))))
514 "Winter Solstice Festival"))))
515
516;;;###holiday-autoload
517(defun holiday-chinese (month day string)
518 "Holiday on Chinese MONTH, DAY called STRING.
519If MONTH, DAY (Chinese) is visible, returns the corresponding
520Gregorian date as the list (((month day year) STRING)).
521Returns nil if it is not visible in the current calendar window."
522 ;; This is calendar-nongregorian-visible-p adapted for the form of
523 ;; chinese dates: (cycle year month day) as opposed to (month day year).
524 (let* ((m1 displayed-month)
525 (y1 displayed-year)
526 (m2 displayed-month)
527 (y2 displayed-year)
528 ;; Absolute date of first/last dates in calendar window.
529 (start-date (progn
530 (calendar-increment-month m1 y1 -1)
531 (calendar-absolute-from-gregorian (list m1 1 y1))))
532 (end-date (progn
533 (calendar-increment-month m2 y2 1)
534 (calendar-absolute-from-gregorian
535 (list m2 (calendar-last-day-of-month m2 y2) y2))))
536 ;; Local date of first/last date in calendar window.
537 (local-start (calendar-chinese-from-absolute start-date))
538 ;; A basic optimization. We only care about the year part,
539 ;; and the Chinese year can only change if Jan or Feb are
540 ;; visible. FIXME can we do more?
541 (local-end (if (memq displayed-month '(12 1 2 3))
542 (calendar-chinese-from-absolute end-date)
543 local-start))
544 ;; When Chinese New Year is visible on the far right of the
545 ;; calendar, what is the earliest Chinese month in the
546 ;; previous year that might still visible? This test doesn't
547 ;; have to be precise.
548 (local (if (< month 10) local-end local-start))
549 (cycle (car local))
550 (year (cadr local))
551 (date (calendar-gregorian-from-absolute
552 (calendar-chinese-to-absolute (list cycle year month day)))))
553 (if (calendar-date-is-visible-p date)
554 (list (list date string)))))
555
490;;;###cal-autoload 556;;;###cal-autoload
491(defun calendar-chinese-date-string (&optional date) 557(defun calendar-chinese-date-string (&optional date)
492 "String of Chinese date of Gregorian DATE. 558 "String of Chinese date of Gregorian DATE.