comparison lisp/calendar/cal-china.el @ 93809:3ff2b47de8f2

Update for calendar.el name changes.
author Glenn Morris <rgm@gnu.org>
date Mon, 07 Apr 2008 01:59:37 +0000
parents 089c13c26a10
children bf9ef749c23e
comparison
equal deleted inserted replaced
93808:2c72483f42c9 93809:3ff2b47de8f2
211 (aref calendar-chinese-terrestrial-branch (% (1- n) 12)))) 211 (aref calendar-chinese-terrestrial-branch (% (1- n) 12))))
212 212
213 (defun calendar-chinese-zodiac-sign-on-or-after (d) 213 (defun calendar-chinese-zodiac-sign-on-or-after (d)
214 "Absolute date of first new Zodiac sign on or after absolute date D. 214 "Absolute date of first new Zodiac sign on or after absolute date D.
215 The Zodiac signs begin when the sun's longitude is a multiple of 30 degrees." 215 The Zodiac signs begin when the sun's longitude is a multiple of 30 degrees."
216 (let* ((year (extract-calendar-year (calendar-gregorian-from-absolute d))) 216 (let* ((year (calendar-extract-year (calendar-gregorian-from-absolute d)))
217 (calendar-time-zone (eval calendar-chinese-time-zone)) ; uses year 217 (calendar-time-zone (eval calendar-chinese-time-zone)) ; uses year
218 (calendar-daylight-time-offset 218 (calendar-daylight-time-offset
219 calendar-chinese-daylight-time-offset) 219 calendar-chinese-daylight-time-offset)
220 (calendar-standard-time-zone-name 220 (calendar-standard-time-zone-name
221 calendar-chinese-standard-time-zone-name) 221 calendar-chinese-standard-time-zone-name)
233 (calendar-astro-to-absolute 233 (calendar-astro-to-absolute
234 (solar-date-next-longitude (calendar-astro-from-absolute d) 30))))) 234 (solar-date-next-longitude (calendar-astro-from-absolute d) 30)))))
235 235
236 (defun calendar-chinese-new-moon-on-or-after (d) 236 (defun calendar-chinese-new-moon-on-or-after (d)
237 "Absolute date of first new moon on or after absolute date D." 237 "Absolute date of first new moon on or after absolute date D."
238 (let* ((year (extract-calendar-year (calendar-gregorian-from-absolute d))) 238 (let* ((year (calendar-extract-year (calendar-gregorian-from-absolute d)))
239 (calendar-time-zone (eval calendar-chinese-time-zone)) 239 (calendar-time-zone (eval calendar-chinese-time-zone))
240 (calendar-daylight-time-offset 240 (calendar-daylight-time-offset
241 calendar-chinese-daylight-time-offset) 241 calendar-chinese-daylight-time-offset)
242 (calendar-standard-time-zone-name 242 (calendar-standard-time-zone-name
243 calendar-chinese-standard-time-zone-name) 243 calendar-chinese-standard-time-zone-name)
432 432
433 (defun calendar-chinese-from-absolute (date) 433 (defun calendar-chinese-from-absolute (date)
434 "Compute Chinese date (cycle year month day) corresponding to absolute DATE. 434 "Compute Chinese date (cycle year month day) corresponding to absolute DATE.
435 The absolute date is the number of days elapsed since the (imaginary) 435 The absolute date is the number of days elapsed since the (imaginary)
436 Gregorian date Sunday, December 31, 1 BC." 436 Gregorian date Sunday, December 31, 1 BC."
437 (let* ((g-year (extract-calendar-year 437 (let* ((g-year (calendar-extract-year
438 (calendar-gregorian-from-absolute date))) 438 (calendar-gregorian-from-absolute date)))
439 (c-year (+ g-year 2695)) 439 (c-year (+ g-year 2695))
440 (list (append (calendar-chinese-year (1- g-year)) 440 (list (append (calendar-chinese-year (1- g-year))
441 (calendar-chinese-year g-year) 441 (calendar-chinese-year g-year)
442 (calendar-chinese-year (1+ g-year))))) 442 (calendar-chinese-year (1+ g-year)))))
452 ;; Remainder of c-year/60 with 60 instead of 0. 452 ;; Remainder of c-year/60 with 60 instead of 0.
453 (1+ (mod (1- c-year) 60)) 453 (1+ (mod (1- c-year) 60))
454 (caar list) 454 (caar list)
455 (1+ (- date (cadr (car list))))))) 455 (1+ (- date (cadr (car list)))))))
456 456
457 ;; Bound in generate-calendar. 457 ;; Bound in calendar-generate.
458 (defvar displayed-month) 458 (defvar displayed-month)
459 (defvar displayed-year) 459 (defvar displayed-year)
460 460
461 ;;;###holiday-autoload 461 ;;;###holiday-autoload
462 (defun holiday-chinese-new-year () 462 (defun holiday-chinese-new-year ()
467 chinese-new-year) 467 chinese-new-year)
468 ;; In the Gregorian calendar, CNY falls between Jan 21 and Feb 20. 468 ;; In the Gregorian calendar, CNY falls between Jan 21 and Feb 20.
469 ;; Jan is visible if displayed-month = 12, 1, 2; Feb if d-m = 1, 2, 3. 469 ;; Jan is visible if displayed-month = 12, 1, 2; Feb if d-m = 1, 2, 3.
470 ;; If we shift the calendar forward one month, we can do a 470 ;; If we shift the calendar forward one month, we can do a
471 ;; one-sided test, namely: d-m <= 4 means CNY might be visible. 471 ;; one-sided test, namely: d-m <= 4 means CNY might be visible.
472 (increment-calendar-month m y 1) ; shift forward a month 472 (calendar-increment-month m y 1) ; shift forward a month
473 (and (< m 5) 473 (and (< m 5)
474 (calendar-date-is-visible-p 474 (calendar-date-is-visible-p
475 (setq chinese-new-year 475 (setq chinese-new-year
476 (calendar-gregorian-from-absolute 476 (calendar-gregorian-from-absolute
477 (cadr (assoc 1 (calendar-chinese-year y)))))) 477 (cadr (assoc 1 (calendar-chinese-year y))))))
544 (defun calendar-chinese-months (c y) 544 (defun calendar-chinese-months (c y)
545 "A list of the months in cycle C, year Y of the Chinese calendar." 545 "A list of the months in cycle C, year Y of the Chinese calendar."
546 (memq 1 (append 546 (memq 1 (append
547 (mapcar (lambda (x) 547 (mapcar (lambda (x)
548 (car x)) 548 (car x))
549 (calendar-chinese-year (extract-calendar-year 549 (calendar-chinese-year (calendar-extract-year
550 (calendar-gregorian-from-absolute 550 (calendar-gregorian-from-absolute
551 (calendar-chinese-to-absolute 551 (calendar-chinese-to-absolute
552 (list c y 1 1)))))) 552 (list c y 1 1))))))
553 (mapcar (lambda (x) 553 (mapcar (lambda (x)
554 (if (> (car x) 11) (car x))) 554 (if (> (car x) 11) (car x)))
555 (calendar-chinese-year (extract-calendar-year 555 (calendar-chinese-year (calendar-extract-year
556 (calendar-gregorian-from-absolute 556 (calendar-gregorian-from-absolute
557 (calendar-chinese-to-absolute 557 (calendar-chinese-to-absolute
558 (list (if (= y 60) (1+ c) c) 558 (list (if (= y 60) (1+ c) c)
559 (if (= y 60) 1 y) 559 (if (= y 60) 1 y)
560 1 1))))))))) 560 1 1)))))))))