Mercurial > emacs
comparison lisp/calendar/cal-china.el @ 94282:70cc209bf336
(holiday-chinese-qingming, holiday-chinese-winter-solstice)
(holiday-chinese): New functions.
author | Glenn Morris <rgm@gnu.org> |
---|---|
date | Wed, 23 Apr 2008 03:03:43 +0000 |
parents | 2834643ba8a0 |
children | e49abd957e81 |
comparison
equal
deleted
inserted
replaced
94281:0cbedba0ce0d | 94282:70cc209bf336 |
---|---|
485 (list | 485 (list |
486 (list chinese-new-year | 486 (list chinese-new-year |
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. | |
493 Returns (((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. | |
506 Returns (((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. | |
519 If MONTH, DAY (Chinese) is visible, returns the corresponding | |
520 Gregorian date as the list (((month day year) STRING)). | |
521 Returns 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. |
493 Defaults to today's date if DATE is not given." | 559 Defaults to today's date if DATE is not given." |
494 (let* ((a-date (calendar-absolute-from-gregorian | 560 (let* ((a-date (calendar-absolute-from-gregorian |