Mercurial > emacs
annotate lisp/calendar/cal-china.el @ 92968:e2f0046a8cb4
(appt-check, appt-delete, appt-make-list): Use caar.
author | Glenn Morris <rgm@gnu.org> |
---|---|
date | Sat, 15 Mar 2008 02:59:34 +0000 |
parents | 4151ef80cb37 |
children | 130c0da046a4 |
rev | line source |
---|---|
38422
7a94f1c588c4
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
23143
diff
changeset
|
1 ;;; cal-china.el --- calendar functions for the Chinese calendar |
13053 | 2 |
92642 | 3 ;; Copyright (C) 1995, 1997, 2001, 2002, 2003, 2004, 2005, 2006, 2007, |
4 ;; 2008 Free Software Foundation, Inc. | |
13053 | 5 |
6 ;; Author: Edward M. Reingold <reingold@cs.uiuc.edu> | |
67465
a55ee709ec8d
Update copyright pending Emacs 22.
Glenn Morris <rgm@gnu.org>
parents:
65142
diff
changeset
|
7 ;; Maintainer: Glenn Morris <rgm@gnu.org> |
13053 | 8 ;; Keywords: calendar |
9 ;; Human-Keywords: Chinese calendar, calendar, holidays, diary | |
10 | |
11 ;; This file is part of GNU Emacs. | |
12 | |
13 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
14 ;; it under the terms of the GNU General Public License as published by | |
78216
93e11478c954
Switch license to GPLv3 or later.
Glenn Morris <rgm@gnu.org>
parents:
77279
diff
changeset
|
15 ;; the Free Software Foundation; either version 3, or (at your option) |
13053 | 16 ;; any later version. |
17 | |
18 ;; GNU Emacs is distributed in the hope that it will be useful, | |
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
21 ;; GNU General Public License for more details. | |
22 | |
23 ;; You should have received a copy of the GNU General Public License | |
14169 | 24 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
64085 | 25 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
26 ;; Boston, MA 02110-1301, USA. | |
13053 | 27 |
28 ;;; Commentary: | |
29 | |
30 ;; This collection of functions implements the features of calendar.el, | |
13281
510f946d1e22
Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13053
diff
changeset
|
31 ;; diary.el, and holidays.el that deal with the Chinese calendar. The rules |
510f946d1e22
Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13053
diff
changeset
|
32 ;; used for the Chinese calendar are those of Baolin Liu (see L. E. Doggett's |
510f946d1e22
Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13053
diff
changeset
|
33 ;; article "Calendars" in the Explanatory Supplement to the Astronomical |
510f946d1e22
Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13053
diff
changeset
|
34 ;; Almanac, second edition, 1992) for the calendar as revised at the beginning |
13283
f8658d1ca0f2
Various fixes and simplifications.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13281
diff
changeset
|
35 ;; of the Qing dynasty in 1644. The nature of the astronomical calculations |
f8658d1ca0f2
Various fixes and simplifications.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13281
diff
changeset
|
36 ;; is such that precise calculations cannot be made without great expense in |
f8658d1ca0f2
Various fixes and simplifications.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13281
diff
changeset
|
37 ;; time, so that the calendars produced may not agree perfectly with published |
f8658d1ca0f2
Various fixes and simplifications.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13281
diff
changeset
|
38 ;; tables--but no two pairs of published tables agree perfectly either! Liu's |
f8658d1ca0f2
Various fixes and simplifications.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13281
diff
changeset
|
39 ;; rules produce a calendar for 2033 which is not accepted by all authorities. |
f8658d1ca0f2
Various fixes and simplifications.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13281
diff
changeset
|
40 ;; The date of Chinese New Year is correct from 1644-2051. |
13053 | 41 |
20462
d179de7ad92e
Add reference to new Calendrical Calculations book.
Paul Eggert <eggert@twinsun.com>
parents:
20215
diff
changeset
|
42 ;; Technical details of all the calendrical calculations can be found in |
61148
7f7db25577d9
Update reference to "Calendrical Calculations" book; there's a new edition.
Paul Eggert <eggert@twinsun.com>
parents:
52401
diff
changeset
|
43 ;; ``Calendrical Calculations: The Millennium Edition'' by Edward M. Reingold |
7f7db25577d9
Update reference to "Calendrical Calculations" book; there's a new edition.
Paul Eggert <eggert@twinsun.com>
parents:
52401
diff
changeset
|
44 ;; and Nachum Dershowitz, Cambridge University Press (2001). |
20462
d179de7ad92e
Add reference to new Calendrical Calculations book.
Paul Eggert <eggert@twinsun.com>
parents:
20215
diff
changeset
|
45 |
92900
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
46 ;; Note to maintainers: |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
47 ;; Use `chinese-year-cache-init' every few years to recenter the default |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
48 ;; value of `chinese-year-cache'. |
13053 | 49 |
92900
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
50 ;;; Code: |
52112
e7d0572ccca5
(displayed-month, displayed-year): Define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
49598
diff
changeset
|
51 |
13053 | 52 (require 'lunar) |
53 | |
92579
8ddfb879916b
Unquote lambda functions. Add autoload cookies to functions formerly
Glenn Morris <rgm@gnu.org>
parents:
92546
diff
changeset
|
54 (defgroup chinese-calendar nil |
8ddfb879916b
Unquote lambda functions. Add autoload cookies to functions formerly
Glenn Morris <rgm@gnu.org>
parents:
92546
diff
changeset
|
55 "Chinese calendar support." |
8ddfb879916b
Unquote lambda functions. Add autoload cookies to functions formerly
Glenn Morris <rgm@gnu.org>
parents:
92546
diff
changeset
|
56 :group 'calendar) |
13053 | 57 |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
38422
diff
changeset
|
58 (defcustom chinese-calendar-time-zone |
13053 | 59 '(if (< year 1928) |
60 (+ 465 (/ 40.0 60.0)) | |
61 480) | |
92660
e64439fb46dc
(chinese-calendar-time-zone, chinese-calendar-daylight-time-offset)
Glenn Morris <rgm@gnu.org>
parents:
92642
diff
changeset
|
62 "Minutes difference between local standard time for Chinese calendar and UTC. |
92900
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
63 Default is for Beijing. This is an expression in `year' since it changed at |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
64 1928-01-01 00:00:00 from UT+7:45:40 to UT+8." |
19903
bfd7fbd77e8a
(chinese-calendar-time-zone): Likewise.
Richard M. Stallman <rms@gnu.org>
parents:
17624
diff
changeset
|
65 :type 'sexp |
17624
7634c31da26e
Add defgroup and use defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
14685
diff
changeset
|
66 :group 'chinese-calendar) |
13053 | 67 |
17624
7634c31da26e
Add defgroup and use defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
14685
diff
changeset
|
68 (defcustom chinese-calendar-location-name "Beijing" |
92546
0ef74aab4b13
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
69 "Name of location used for calculation of Chinese calendar." |
17624
7634c31da26e
Add defgroup and use defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
14685
diff
changeset
|
70 :type 'string |
7634c31da26e
Add defgroup and use defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
14685
diff
changeset
|
71 :group 'chinese-calendar) |
13053 | 72 |
17624
7634c31da26e
Add defgroup and use defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
14685
diff
changeset
|
73 (defcustom chinese-calendar-daylight-time-offset 0 |
92642 | 74 ;; The correct value is as follows, but the Chinese calendrical |
75 ;; authorities do NOT use DST in determining astronomical events: | |
76 ;; 60 | |
92660
e64439fb46dc
(chinese-calendar-time-zone, chinese-calendar-daylight-time-offset)
Glenn Morris <rgm@gnu.org>
parents:
92642
diff
changeset
|
77 "Minutes difference between daylight saving and standard time. |
e64439fb46dc
(chinese-calendar-time-zone, chinese-calendar-daylight-time-offset)
Glenn Morris <rgm@gnu.org>
parents:
92642
diff
changeset
|
78 Default is for no daylight saving time." |
17624
7634c31da26e
Add defgroup and use defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
14685
diff
changeset
|
79 :type 'integer |
7634c31da26e
Add defgroup and use defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
14685
diff
changeset
|
80 :group 'chinese-calendar) |
13053 | 81 |
17624
7634c31da26e
Add defgroup and use defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
14685
diff
changeset
|
82 (defcustom chinese-calendar-standard-time-zone-name |
13053 | 83 '(if (< year 1928) |
84 "PMT" | |
85 "CST") | |
92546
0ef74aab4b13
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
86 "Abbreviated name of standard time zone used for Chinese calendar. |
19903
bfd7fbd77e8a
(chinese-calendar-time-zone): Likewise.
Richard M. Stallman <rms@gnu.org>
parents:
17624
diff
changeset
|
87 This is an expression depending on `year' because it changed |
bfd7fbd77e8a
(chinese-calendar-time-zone): Likewise.
Richard M. Stallman <rms@gnu.org>
parents:
17624
diff
changeset
|
88 at 1928-01-01 00:00:00 from `PMT' to `CST'." |
bfd7fbd77e8a
(chinese-calendar-time-zone): Likewise.
Richard M. Stallman <rms@gnu.org>
parents:
17624
diff
changeset
|
89 :type 'sexp |
17624
7634c31da26e
Add defgroup and use defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
14685
diff
changeset
|
90 :group 'chinese-calendar) |
13053 | 91 |
17624
7634c31da26e
Add defgroup and use defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
14685
diff
changeset
|
92 (defcustom chinese-calendar-daylight-time-zone-name "CDT" |
92546
0ef74aab4b13
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
93 "Abbreviated name of daylight saving time zone used for Chinese calendar." |
17624
7634c31da26e
Add defgroup and use defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
14685
diff
changeset
|
94 :type 'string |
7634c31da26e
Add defgroup and use defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
14685
diff
changeset
|
95 :group 'chinese-calendar) |
13053 | 96 |
17624
7634c31da26e
Add defgroup and use defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
14685
diff
changeset
|
97 (defcustom chinese-calendar-daylight-savings-starts nil |
92642 | 98 ;; The correct value is as follows, but the Chinese calendrical |
99 ;; authorities do NOT use DST in determining astronomical events: | |
100 ;; '(cond ((< 1986 year) (calendar-nth-named-day 1 0 4 year 10)) | |
101 ;; ((= 1986 year) '(5 4 1986)) | |
102 ;; (t nil)) | |
92660
e64439fb46dc
(chinese-calendar-time-zone, chinese-calendar-daylight-time-offset)
Glenn Morris <rgm@gnu.org>
parents:
92642
diff
changeset
|
103 "Sexp giving the date on which daylight saving time starts. |
e64439fb46dc
(chinese-calendar-time-zone, chinese-calendar-daylight-time-offset)
Glenn Morris <rgm@gnu.org>
parents:
92642
diff
changeset
|
104 Default is for no daylight saving time. See documentation of |
17624
7634c31da26e
Add defgroup and use defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
14685
diff
changeset
|
105 `calendar-daylight-savings-starts'." |
7634c31da26e
Add defgroup and use defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
14685
diff
changeset
|
106 :type 'sexp |
7634c31da26e
Add defgroup and use defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
14685
diff
changeset
|
107 :group 'chinese-calendar) |
13053 | 108 |
17624
7634c31da26e
Add defgroup and use defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
14685
diff
changeset
|
109 (defcustom chinese-calendar-daylight-savings-ends nil |
92642 | 110 ;; The correct value is as follows, but the Chinese calendrical |
111 ;; authorities do NOT use DST in determining astronomical events: | |
112 ;; '(if (<= 1986 year) (calendar-nth-named-day 1 0 9 year 11)) | |
92660
e64439fb46dc
(chinese-calendar-time-zone, chinese-calendar-daylight-time-offset)
Glenn Morris <rgm@gnu.org>
parents:
92642
diff
changeset
|
113 "Sexp giving the date on which daylight saving time ends. |
e64439fb46dc
(chinese-calendar-time-zone, chinese-calendar-daylight-time-offset)
Glenn Morris <rgm@gnu.org>
parents:
92642
diff
changeset
|
114 Default is for no daylight saving time. See documentation of |
17624
7634c31da26e
Add defgroup and use defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
14685
diff
changeset
|
115 `calendar-daylight-savings-ends'." |
7634c31da26e
Add defgroup and use defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
14685
diff
changeset
|
116 :type 'sexp |
7634c31da26e
Add defgroup and use defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
14685
diff
changeset
|
117 :group 'chinese-calendar) |
13053 | 118 |
17624
7634c31da26e
Add defgroup and use defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
14685
diff
changeset
|
119 (defcustom chinese-calendar-daylight-savings-starts-time 0 |
92660
e64439fb46dc
(chinese-calendar-time-zone, chinese-calendar-daylight-time-offset)
Glenn Morris <rgm@gnu.org>
parents:
92642
diff
changeset
|
120 "Number of minutes after midnight that daylight saving time starts. |
e64439fb46dc
(chinese-calendar-time-zone, chinese-calendar-daylight-time-offset)
Glenn Morris <rgm@gnu.org>
parents:
92642
diff
changeset
|
121 Default is for no daylight saving time." |
17624
7634c31da26e
Add defgroup and use defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
14685
diff
changeset
|
122 :type 'integer |
7634c31da26e
Add defgroup and use defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
14685
diff
changeset
|
123 :group 'chinese-calendar) |
13053 | 124 |
17624
7634c31da26e
Add defgroup and use defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
14685
diff
changeset
|
125 (defcustom chinese-calendar-daylight-savings-ends-time 0 |
92660
e64439fb46dc
(chinese-calendar-time-zone, chinese-calendar-daylight-time-offset)
Glenn Morris <rgm@gnu.org>
parents:
92642
diff
changeset
|
126 "Number of minutes after midnight that daylight saving time ends. |
e64439fb46dc
(chinese-calendar-time-zone, chinese-calendar-daylight-time-offset)
Glenn Morris <rgm@gnu.org>
parents:
92642
diff
changeset
|
127 Default is for no daylight saving time." |
17624
7634c31da26e
Add defgroup and use defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
14685
diff
changeset
|
128 :type 'integer |
7634c31da26e
Add defgroup and use defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
14685
diff
changeset
|
129 :group 'chinese-calendar) |
13053 | 130 |
92579
8ddfb879916b
Unquote lambda functions. Add autoload cookies to functions formerly
Glenn Morris <rgm@gnu.org>
parents:
92546
diff
changeset
|
131 ;;; End of user options. |
8ddfb879916b
Unquote lambda functions. Add autoload cookies to functions formerly
Glenn Morris <rgm@gnu.org>
parents:
92546
diff
changeset
|
132 |
8ddfb879916b
Unquote lambda functions. Add autoload cookies to functions formerly
Glenn Morris <rgm@gnu.org>
parents:
92546
diff
changeset
|
133 |
8ddfb879916b
Unquote lambda functions. Add autoload cookies to functions formerly
Glenn Morris <rgm@gnu.org>
parents:
92546
diff
changeset
|
134 (defconst chinese-calendar-celestial-stem |
92900
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
135 ["Jia" "Yi" "Bing" "Ding" "Wu" "Ji" "Geng" "Xin" "Ren" "Gui"] |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
136 "Prefixes used by `calendar-chinese-sexagesimal-name'.") |
92579
8ddfb879916b
Unquote lambda functions. Add autoload cookies to functions formerly
Glenn Morris <rgm@gnu.org>
parents:
92546
diff
changeset
|
137 |
8ddfb879916b
Unquote lambda functions. Add autoload cookies to functions formerly
Glenn Morris <rgm@gnu.org>
parents:
92546
diff
changeset
|
138 (defconst chinese-calendar-terrestrial-branch |
92900
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
139 ["Zi" "Chou" "Yin" "Mao" "Chen" "Si" "Wu" "Wei" "Shen" "You" "Xu" "Hai"] |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
140 "Suffixes used by `calendar-chinese-sexagesimal-name'.") |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
141 |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
142 (defun calendar-chinese-sexagesimal-name (n) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
143 "The N-th name of the Chinese sexagesimal cycle. |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
144 N congruent to 1 gives the first name, N congruent to 2 gives the second name, |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
145 ..., N congruent to 60 gives the sixtieth name." |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
146 (format "%s-%s" |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
147 (aref chinese-calendar-celestial-stem (% (1- n) 10)) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
148 (aref chinese-calendar-terrestrial-branch (% (1- n) 12)))) |
92579
8ddfb879916b
Unquote lambda functions. Add autoload cookies to functions formerly
Glenn Morris <rgm@gnu.org>
parents:
92546
diff
changeset
|
149 |
13053 | 150 (defun chinese-zodiac-sign-on-or-after (d) |
92660
e64439fb46dc
(chinese-calendar-time-zone, chinese-calendar-daylight-time-offset)
Glenn Morris <rgm@gnu.org>
parents:
92642
diff
changeset
|
151 "Absolute date of first new Zodiac sign on or after absolute date D. |
13053 | 152 The Zodiac signs begin when the sun's longitude is a multiple of 30 degrees." |
92900
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
153 (let* ((year (extract-calendar-year (calendar-gregorian-from-absolute d))) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
154 (calendar-time-zone (eval chinese-calendar-time-zone)) ; uses year |
13053 | 155 (calendar-daylight-time-offset |
156 chinese-calendar-daylight-time-offset) | |
157 (calendar-standard-time-zone-name | |
158 chinese-calendar-standard-time-zone-name) | |
159 (calendar-daylight-time-zone-name | |
160 chinese-calendar-daylight-time-zone-name) | |
161 (calendar-calendar-daylight-savings-starts | |
162 chinese-calendar-daylight-savings-starts) | |
163 (calendar-daylight-savings-ends | |
164 chinese-calendar-daylight-savings-ends) | |
165 (calendar-daylight-savings-starts-time | |
166 chinese-calendar-daylight-savings-starts-time) | |
167 (calendar-daylight-savings-ends-time | |
168 chinese-calendar-daylight-savings-ends-time)) | |
169 (floor | |
170 (calendar-absolute-from-astro | |
92900
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
171 (solar-date-next-longitude (calendar-astro-from-absolute d) 30))))) |
13053 | 172 |
173 (defun chinese-new-moon-on-or-after (d) | |
92660
e64439fb46dc
(chinese-calendar-time-zone, chinese-calendar-daylight-time-offset)
Glenn Morris <rgm@gnu.org>
parents:
92642
diff
changeset
|
174 "Absolute date of first new moon on or after absolute date D." |
92900
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
175 (let* ((year (extract-calendar-year (calendar-gregorian-from-absolute d))) |
13053 | 176 (calendar-time-zone (eval chinese-calendar-time-zone)) |
177 (calendar-daylight-time-offset | |
178 chinese-calendar-daylight-time-offset) | |
179 (calendar-standard-time-zone-name | |
180 chinese-calendar-standard-time-zone-name) | |
181 (calendar-daylight-time-zone-name | |
182 chinese-calendar-daylight-time-zone-name) | |
183 (calendar-calendar-daylight-savings-starts | |
184 chinese-calendar-daylight-savings-starts) | |
185 (calendar-daylight-savings-ends | |
186 chinese-calendar-daylight-savings-ends) | |
187 (calendar-daylight-savings-starts-time | |
188 chinese-calendar-daylight-savings-starts-time) | |
189 (calendar-daylight-savings-ends-time | |
190 chinese-calendar-daylight-savings-ends-time)) | |
191 (floor | |
192 (calendar-absolute-from-astro | |
92900
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
193 (lunar-new-moon-on-or-after (calendar-astro-from-absolute d)))))) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
194 |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
195 (defun chinese-month-list (start end) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
196 "List of starting dates of Chinese months from START to END." |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
197 (if (<= start end) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
198 (let ((new-moon (chinese-new-moon-on-or-after start))) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
199 (if (<= new-moon end) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
200 (cons new-moon |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
201 (chinese-month-list (1+ new-moon) end)))))) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
202 |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
203 (defun number-chinese-months (list start) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
204 "Assign month numbers to the lunar months in LIST, starting with START. |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
205 Numbers are assigned sequentially, START, START+1, ..., 11, with |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
206 half numbers used for leap months. First and last months of list |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
207 are never leap months." |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
208 (when list |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
209 (cons (list start (car list)) ; first month |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
210 ;; Remaining months. |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
211 (if (zerop (- 12 start (length list))) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
212 ;; List is too short for a leap month. |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
213 (number-chinese-months (cdr list) (1+ start)) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
214 (if (and (cddr list) ; at least two more months... |
92967
4151ef80cb37
(number-chinese-months, calendar-chinese-from-absolute): Use nth, caar.
Glenn Morris <rgm@gnu.org>
parents:
92900
diff
changeset
|
215 (<= (nth 2 list) |
92900
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
216 (chinese-zodiac-sign-on-or-after (cadr list)))) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
217 ;; Next month is a leap month. |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
218 (cons (list (+ start 0.5) (cadr list)) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
219 (number-chinese-months (cddr list) (1+ start))) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
220 ;; Next month is not a leap month. |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
221 (number-chinese-months (cdr list) (1+ start))))))) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
222 |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
223 (defun compute-chinese-year (y) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
224 "Compute the structure of the Chinese year for Gregorian year Y. |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
225 The result is a list of pairs (i d), where month i begins on absolute date d, |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
226 of the Chinese months from the Chinese month following the solstice in |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
227 Gregorian year Y-1 to the Chinese month of the solstice of Gregorian year Y." |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
228 (let* ((next-solstice (chinese-zodiac-sign-on-or-after |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
229 (calendar-absolute-from-gregorian |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
230 (list 12 15 y)))) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
231 (list (chinese-month-list (1+ (chinese-zodiac-sign-on-or-after |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
232 (calendar-absolute-from-gregorian |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
233 (list 12 15 (1- y))))) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
234 next-solstice)) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
235 (next-sign (chinese-zodiac-sign-on-or-after (car list)))) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
236 (if (= (length list) 12) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
237 ;; No room for a leap month, just number them 12, 1, 2, ..., 11. |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
238 (cons (list 12 (car list)) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
239 (number-chinese-months (cdr list) 1)) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
240 ;; Now we can assign numbers to the list for y. |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
241 ;; The first month or two are special. |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
242 (if (or (> (car list) next-sign) (>= next-sign (cadr list))) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
243 ;; First month on list is a leap month, second is not. |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
244 (append (list (list 11.5 (car list)) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
245 (list 12 (cadr list))) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
246 (number-chinese-months (cddr list) 1)) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
247 ;; First month on list is not a leap month. |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
248 (append (list (list 12 (car list))) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
249 (if (>= (chinese-zodiac-sign-on-or-after (cadr list)) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
250 (nth 2 list)) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
251 ;; Second month on list is a leap month. |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
252 (cons (list 12.5 (cadr list)) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
253 (number-chinese-months (cddr list) 1)) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
254 ;; Second month on list is not a leap month. |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
255 (number-chinese-months (cdr list) 1))))))) |
13053 | 256 |
13281
510f946d1e22
Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13053
diff
changeset
|
257 (defvar chinese-year-cache |
92900
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
258 ;; Maintainers: delete existing value, position point at start of |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
259 ;; empty line, then call M-: (chinese-year-cache-init N) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
260 '((2000 (12 730126) (1 730155) (2 730185) (3 730215) (4 730244) (5 730273) |
23143
cbd4013c57ab
(chinese-year-cache): Change range of years from
Karl Heuer <kwzh@gnu.org>
parents:
20462
diff
changeset
|
261 (6 730303) (7 730332) (8 730361) (9 730391) (10 730420) (11 730450)) |
cbd4013c57ab
(chinese-year-cache): Change range of years from
Karl Heuer <kwzh@gnu.org>
parents:
20462
diff
changeset
|
262 (2001 (12 730480) (1 730509) (2 730539) (3 730569) (4 730598) (4.5 730628) |
cbd4013c57ab
(chinese-year-cache): Change range of years from
Karl Heuer <kwzh@gnu.org>
parents:
20462
diff
changeset
|
263 (5 730657) (6 730687) (7 730716) (8 730745) (9 730775) (10 730804) |
cbd4013c57ab
(chinese-year-cache): Change range of years from
Karl Heuer <kwzh@gnu.org>
parents:
20462
diff
changeset
|
264 (11 730834)) |
cbd4013c57ab
(chinese-year-cache): Change range of years from
Karl Heuer <kwzh@gnu.org>
parents:
20462
diff
changeset
|
265 (2002 (12 730863) (1 730893) (2 730923) (3 730953) (4 730982) (5 731012) |
cbd4013c57ab
(chinese-year-cache): Change range of years from
Karl Heuer <kwzh@gnu.org>
parents:
20462
diff
changeset
|
266 (6 731041) (7 731071) (8 731100) (9 731129) (10 731159) (11 731188)) |
cbd4013c57ab
(chinese-year-cache): Change range of years from
Karl Heuer <kwzh@gnu.org>
parents:
20462
diff
changeset
|
267 (2003 (12 731218) (1 731247) (2 731277) (3 731307) (4 731336) (5 731366) |
cbd4013c57ab
(chinese-year-cache): Change range of years from
Karl Heuer <kwzh@gnu.org>
parents:
20462
diff
changeset
|
268 (6 731396) (7 731425) (8 731455) (9 731484) (10 731513) (11 731543)) |
cbd4013c57ab
(chinese-year-cache): Change range of years from
Karl Heuer <kwzh@gnu.org>
parents:
20462
diff
changeset
|
269 (2004 (12 731572) (1 731602) (2 731631) (2.5 731661) (3 731690) (4 731720) |
cbd4013c57ab
(chinese-year-cache): Change range of years from
Karl Heuer <kwzh@gnu.org>
parents:
20462
diff
changeset
|
270 (5 731750) (6 731779) (7 731809) (8 731838) (9 731868) (10 731897) |
cbd4013c57ab
(chinese-year-cache): Change range of years from
Karl Heuer <kwzh@gnu.org>
parents:
20462
diff
changeset
|
271 (11 731927)) |
cbd4013c57ab
(chinese-year-cache): Change range of years from
Karl Heuer <kwzh@gnu.org>
parents:
20462
diff
changeset
|
272 (2005 (12 731956) (1 731986) (2 732015) (3 732045) (4 732074) (5 732104) |
cbd4013c57ab
(chinese-year-cache): Change range of years from
Karl Heuer <kwzh@gnu.org>
parents:
20462
diff
changeset
|
273 (6 732133) (7 732163) (8 732193) (9 732222) (10 732252) (11 732281)) |
cbd4013c57ab
(chinese-year-cache): Change range of years from
Karl Heuer <kwzh@gnu.org>
parents:
20462
diff
changeset
|
274 (2006 (12 732311) (1 732340) (2 732370) (3 732399) (4 732429) (5 732458) |
cbd4013c57ab
(chinese-year-cache): Change range of years from
Karl Heuer <kwzh@gnu.org>
parents:
20462
diff
changeset
|
275 (6 732488) (7 732517) (7.5 732547) (8 732576) (9 732606) (10 732636) |
cbd4013c57ab
(chinese-year-cache): Change range of years from
Karl Heuer <kwzh@gnu.org>
parents:
20462
diff
changeset
|
276 (11 732665)) |
cbd4013c57ab
(chinese-year-cache): Change range of years from
Karl Heuer <kwzh@gnu.org>
parents:
20462
diff
changeset
|
277 (2007 (12 732695) (1 732725) (2 732754) (3 732783) (4 732813) (5 732842) |
cbd4013c57ab
(chinese-year-cache): Change range of years from
Karl Heuer <kwzh@gnu.org>
parents:
20462
diff
changeset
|
278 (6 732871) (7 732901) (8 732930) (9 732960) (10 732990) (11 733020)) |
cbd4013c57ab
(chinese-year-cache): Change range of years from
Karl Heuer <kwzh@gnu.org>
parents:
20462
diff
changeset
|
279 (2008 (12 733049) (1 733079) (2 733109) (3 733138) (4 733167) (5 733197) |
cbd4013c57ab
(chinese-year-cache): Change range of years from
Karl Heuer <kwzh@gnu.org>
parents:
20462
diff
changeset
|
280 (6 733226) (7 733255) (8 733285) (9 733314) (10 733344) (11 733374)) |
cbd4013c57ab
(chinese-year-cache): Change range of years from
Karl Heuer <kwzh@gnu.org>
parents:
20462
diff
changeset
|
281 (2009 (12 733403) (1 733433) (2 733463) (3 733493) (4 733522) (5 733551) |
cbd4013c57ab
(chinese-year-cache): Change range of years from
Karl Heuer <kwzh@gnu.org>
parents:
20462
diff
changeset
|
282 (5.5 733581) (6 733610) (7 733639) (8 733669) (9 733698) (10 733728) |
cbd4013c57ab
(chinese-year-cache): Change range of years from
Karl Heuer <kwzh@gnu.org>
parents:
20462
diff
changeset
|
283 (11 733757)) |
cbd4013c57ab
(chinese-year-cache): Change range of years from
Karl Heuer <kwzh@gnu.org>
parents:
20462
diff
changeset
|
284 (2010 (12 733787) (1 733817) (2 733847) (3 733876) (4 733906) (5 733935) |
92900
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
285 (6 733965) (7 733994) (8 734023) (9 734053) (10 734082) (11 734112)) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
286 (2011 (12 734141) (1 734171) (2 734201) (3 734230) (4 734260) (5 734290) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
287 (6 734319) (7 734349) (8 734378) (9 734407) (10 734437) (11 734466)) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
288 (2012 (12 734496) (1 734525) (2 734555) (3 734584) (4 734614) (4.5 734644) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
289 (5 734673) (6 734703) (7 734732) (8 734762) (9 734791) (10 734821) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
290 (11 734850)) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
291 (2013 (12 734880) (1 734909) (2 734939) (3 734968) (4 734998) (5 735027) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
292 (6 735057) (7 735087) (8 735116) (9 735146) (10 735175) (11 735205)) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
293 (2014 (12 735234) (1 735264) (2 735293) (3 735323) (4 735352) (5 735382) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
294 (6 735411) (7 735441) (8 735470) (9 735500) (9.5 735530) (10 735559) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
295 (11 735589)) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
296 (2015 (12 735618) (1 735648) (2 735677) (3 735707) (4 735736) (5 735765) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
297 (6 735795) (7 735824) (8 735854) (9 735884) (10 735914) (11 735943)) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
298 (2016 (12 735973) (1 736002) (2 736032) (3 736061) (4 736091) (5 736120) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
299 (6 736149) (7 736179) (8 736208) (9 736238) (10 736268) (11 736297)) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
300 (2017 (12 736327) (1 736357) (2 736386) (3 736416) (4 736445) (5 736475) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
301 (6 736504) (6.5 736533) (7 736563) (8 736592) (9 736622) (10 736651) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
302 (11 736681)) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
303 (2018 (12 736711) (1 736741) (2 736770) (3 736800) (4 736829) (5 736859) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
304 (6 736888) (7 736917) (8 736947) (9 736976) (10 737006) (11 737035)) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
305 (2019 (12 737065) (1 737095) (2 737125) (3 737154) (4 737184) (5 737213) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
306 (6 737243) (7 737272) (8 737301) (9 737331) (10 737360) (11 737389)) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
307 (2020 (12 737419) (1 737449) (2 737478) (3 737508) (4 737538) (4.5 737568) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
308 (5 737597) (6 737627) (7 737656) (8 737685) (9 737715) (10 737744) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
309 (11 737774))) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
310 "Alist of Chinese year structures as determined by `chinese-year'. |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
311 The default can be nil, but some values are precomputed for efficiency.") |
13281
510f946d1e22
Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13053
diff
changeset
|
312 |
510f946d1e22
Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13053
diff
changeset
|
313 (defun chinese-year (y) |
510f946d1e22
Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13053
diff
changeset
|
314 "The structure of the Chinese year for Gregorian year Y. |
13574
c5d4269e17d9
Minor fixes.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13306
diff
changeset
|
315 The result is a list of pairs (i d), where month i begins on absolute date d, |
13281
510f946d1e22
Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13053
diff
changeset
|
316 of the Chinese months from the Chinese month following the solstice in |
510f946d1e22
Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13053
diff
changeset
|
317 Gregorian year Y-1 to the Chinese month of the solstice of Gregorian year Y. |
92900
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
318 The list is cached in `chinese-year-cache' for further use." |
13281
510f946d1e22
Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13053
diff
changeset
|
319 (let ((list (cdr (assoc y chinese-year-cache)))) |
92900
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
320 (or list |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
321 (setq list (compute-chinese-year y) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
322 chinese-year-cache (append chinese-year-cache |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
323 (list (cons y list))))) |
13281
510f946d1e22
Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13053
diff
changeset
|
324 list)) |
510f946d1e22
Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13053
diff
changeset
|
325 |
92900
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
326 ;; Maintainer use. |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
327 (defun chinese-year-cache-init (year) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
328 "Insert an initialization value for `chinese-year-cache' after point. |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
329 Computes values for 10 years either side of YEAR." |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
330 (setq year (- year 10)) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
331 (let (chinese-year-cache end) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
332 (save-excursion |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
333 (insert "'(") |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
334 (dotimes (n 21) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
335 (princ (cons year (compute-chinese-year year)) (current-buffer)) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
336 (insert (if (= n 20) ")" "\n")) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
337 (setq year (1+ year))) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
338 (setq end (point))) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
339 (save-excursion |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
340 ;; fill-column -/+ 5. |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
341 (while (and (< (point) end) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
342 (re-search-forward "^.\\{65,75\\})" end t)) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
343 (delete-char 1) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
344 (insert "\n"))) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
345 (indent-region (point) end))) |
13281
510f946d1e22
Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13053
diff
changeset
|
346 |
13053 | 347 (defun calendar-absolute-from-chinese (date) |
348 "The number of days elapsed between the Gregorian date 12/31/1 BC and DATE. | |
92900
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
349 DATE is a Chinese date (cycle year month day). The Gregorian date |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
350 Sunday, December 31, 1 BC is imaginary." |
13053 | 351 (let* ((cycle (car date)) |
92900
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
352 (year (cadr date)) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
353 (month (nth 2 date)) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
354 (day (nth 3 date)) |
92642 | 355 (g-year (+ (* (1- cycle) 60) ; years in prior cycles |
356 (1- year) ; prior years this cycle | |
357 -2636))) ; years before absolute date 0 | |
358 (+ (1- day) ; prior days this month | |
92900
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
359 (cadr ; absolute date of start of this month |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
360 (assoc month (append (memq (assoc 1 (chinese-year g-year)) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
361 (chinese-year g-year)) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
362 (chinese-year (1+ g-year)))))))) |
13053 | 363 |
364 (defun calendar-chinese-from-absolute (date) | |
365 "Compute Chinese date (cycle year month day) corresponding to absolute DATE. | |
366 The absolute date is the number of days elapsed since the (imaginary) | |
367 Gregorian date Sunday, December 31, 1 BC." | |
13281
510f946d1e22
Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13053
diff
changeset
|
368 (let* ((g-year (extract-calendar-year |
510f946d1e22
Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13053
diff
changeset
|
369 (calendar-gregorian-from-absolute date))) |
13574
c5d4269e17d9
Minor fixes.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13306
diff
changeset
|
370 (c-year (+ g-year 2695)) |
13281
510f946d1e22
Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13053
diff
changeset
|
371 (list (append (chinese-year (1- g-year)) |
510f946d1e22
Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13053
diff
changeset
|
372 (chinese-year g-year) |
510f946d1e22
Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13053
diff
changeset
|
373 (chinese-year (1+ g-year))))) |
92967
4151ef80cb37
(number-chinese-months, calendar-chinese-from-absolute): Use nth, caar.
Glenn Morris <rgm@gnu.org>
parents:
92900
diff
changeset
|
374 (while (<= (cadr (cadr list)) date) |
92642 | 375 ;; The first month on the list is in Chinese year c-year. |
376 ;; Date is on or after start of second month on list... | |
92967
4151ef80cb37
(number-chinese-months, calendar-chinese-from-absolute): Use nth, caar.
Glenn Morris <rgm@gnu.org>
parents:
92900
diff
changeset
|
377 (if (= 1 (caar (cdr list))) |
92642 | 378 ;; Second month on list is a new Chinese year... |
13574
c5d4269e17d9
Minor fixes.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13306
diff
changeset
|
379 (setq c-year (1+ c-year))) |
92642 | 380 ;; ...so first month on list is of no interest. |
13281
510f946d1e22
Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13053
diff
changeset
|
381 (setq list (cdr list))) |
13574
c5d4269e17d9
Minor fixes.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13306
diff
changeset
|
382 (list (/ (1- c-year) 60) |
c5d4269e17d9
Minor fixes.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13306
diff
changeset
|
383 (calendar-mod c-year 60) |
92967
4151ef80cb37
(number-chinese-months, calendar-chinese-from-absolute): Use nth, caar.
Glenn Morris <rgm@gnu.org>
parents:
92900
diff
changeset
|
384 (caar list) |
4151ef80cb37
(number-chinese-months, calendar-chinese-from-absolute): Use nth, caar.
Glenn Morris <rgm@gnu.org>
parents:
92900
diff
changeset
|
385 (1+ (- date (cadr (car list))))))) |
13053 | 386 |
92900
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
387 ;; Bound in generate-calendar. |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
388 (defvar displayed-month) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
389 (defvar displayed-year) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
390 |
92827
02fc7543d146
(generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents:
92660
diff
changeset
|
391 ;;;###holiday-autoload |
13053 | 392 (defun holiday-chinese-new-year () |
393 "Date of Chinese New Year." | |
394 (let ((m displayed-month) | |
395 (y displayed-year)) | |
396 (increment-calendar-month m y 1) | |
397 (if (< m 5) | |
398 (let ((chinese-new-year | |
399 (calendar-gregorian-from-absolute | |
92900
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
400 (cadr (assoc 1 (chinese-year y)))))) |
13053 | 401 (if (calendar-date-is-visible-p chinese-new-year) |
13306
77d8e407592e
Fix the way the sexagisimal names are calculated.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13284
diff
changeset
|
402 (list |
77d8e407592e
Fix the way the sexagisimal names are calculated.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13284
diff
changeset
|
403 (list chinese-new-year |
77d8e407592e
Fix the way the sexagisimal names are calculated.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13284
diff
changeset
|
404 (format "Chinese New Year (%s)" |
13675
280cee006df8
(calendar-chinese-sexagesimal-name): Renamed from
Paul Eggert <eggert@twinsun.com>
parents:
13574
diff
changeset
|
405 (calendar-chinese-sexagesimal-name (+ y 57)))))))))) |
13053 | 406 |
92827
02fc7543d146
(generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents:
92660
diff
changeset
|
407 ;;;###cal-autoload |
13053 | 408 (defun calendar-chinese-date-string (&optional date) |
409 "String of Chinese date of Gregorian DATE. | |
410 Defaults to today's date if DATE is not given." | |
411 (let* ((a-date (calendar-absolute-from-gregorian | |
412 (or date (calendar-current-date)))) | |
413 (c-date (calendar-chinese-from-absolute a-date)) | |
414 (cycle (car c-date)) | |
92900
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
415 (year (cadr c-date)) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
416 (month (nth 2 c-date)) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
417 (day (nth 3 c-date)) |
13053 | 418 (this-month (calendar-absolute-from-chinese |
419 (list cycle year month 1))) | |
420 (next-month (calendar-absolute-from-chinese | |
13283
f8658d1ca0f2
Various fixes and simplifications.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13281
diff
changeset
|
421 (list (if (= year 60) (1+ cycle) cycle) |
f8658d1ca0f2
Various fixes and simplifications.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13281
diff
changeset
|
422 (if (= (floor month) 12) (1+ year) year) |
f8658d1ca0f2
Various fixes and simplifications.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13281
diff
changeset
|
423 (calendar-mod (1+ (floor month)) 12) |
f8658d1ca0f2
Various fixes and simplifications.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13281
diff
changeset
|
424 1))) |
13281
510f946d1e22
Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13053
diff
changeset
|
425 (m-cycle (% (+ (* year 5) (floor month)) 60))) |
13306
77d8e407592e
Fix the way the sexagisimal names are calculated.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13284
diff
changeset
|
426 (format "Cycle %s, year %s (%s), %smonth %s%s, day %s (%s)" |
13053 | 427 cycle |
13675
280cee006df8
(calendar-chinese-sexagesimal-name): Renamed from
Paul Eggert <eggert@twinsun.com>
parents:
13574
diff
changeset
|
428 year (calendar-chinese-sexagesimal-name year) |
13053 | 429 (if (not (integerp month)) |
430 "second " | |
431 (if (< 30 (- next-month this-month)) | |
432 "first " | |
433 "")) | |
13281
510f946d1e22
Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13053
diff
changeset
|
434 (floor month) |
13306
77d8e407592e
Fix the way the sexagisimal names are calculated.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13284
diff
changeset
|
435 (if (integerp month) |
13675
280cee006df8
(calendar-chinese-sexagesimal-name): Renamed from
Paul Eggert <eggert@twinsun.com>
parents:
13574
diff
changeset
|
436 (format " (%s)" (calendar-chinese-sexagesimal-name |
20215
13b173216a3d
(calendar-chinese-date-string): Fix month name.
Karl Heuer <kwzh@gnu.org>
parents:
19903
diff
changeset
|
437 (+ (* 12 year) month 50))) |
13306
77d8e407592e
Fix the way the sexagisimal names are calculated.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13284
diff
changeset
|
438 "") |
13675
280cee006df8
(calendar-chinese-sexagesimal-name): Renamed from
Paul Eggert <eggert@twinsun.com>
parents:
13574
diff
changeset
|
439 day (calendar-chinese-sexagesimal-name (+ a-date 15))))) |
13306
77d8e407592e
Fix the way the sexagisimal names are calculated.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13284
diff
changeset
|
440 |
92827
02fc7543d146
(generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents:
92660
diff
changeset
|
441 ;;;###cal-autoload |
13053 | 442 (defun calendar-print-chinese-date () |
443 "Show the Chinese date equivalents of date." | |
444 (interactive) | |
445 (message "Computing Chinese date...") | |
446 (message "Chinese date: %s" | |
447 (calendar-chinese-date-string (calendar-cursor-to-date t)))) | |
448 | |
92900
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
449 (defun make-chinese-month-assoc-list (l) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
450 "Make list of months L into an assoc list." |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
451 (and l (car l) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
452 (if (and (cdr l) (cadr l)) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
453 (if (= (car l) (floor (cadr l))) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
454 (append |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
455 (list (cons (format "%s (first)" (car l)) (car l)) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
456 (cons (format "%s (second)" (car l)) (cadr l))) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
457 (make-chinese-month-assoc-list (cddr l))) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
458 (append |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
459 (list (cons (int-to-string (car l)) (car l))) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
460 (make-chinese-month-assoc-list (cdr l)))) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
461 (list (cons (int-to-string (car l)) (car l)))))) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
462 |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
463 (defun chinese-months (c y) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
464 "A list of the months in cycle C, year Y of the Chinese calendar." |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
465 (memq 1 (append |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
466 (mapcar (lambda (x) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
467 (car x)) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
468 (chinese-year (extract-calendar-year |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
469 (calendar-gregorian-from-absolute |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
470 (calendar-absolute-from-chinese |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
471 (list c y 1 1)))))) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
472 (mapcar (lambda (x) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
473 (if (> (car x) 11) (car x))) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
474 (chinese-year (extract-calendar-year |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
475 (calendar-gregorian-from-absolute |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
476 (calendar-absolute-from-chinese |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
477 (list (if (= y 60) (1+ c) c) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
478 (if (= y 60) 1 y) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
479 1 1))))))))) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
480 |
92827
02fc7543d146
(generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents:
92660
diff
changeset
|
481 ;;;###cal-autoload |
13053 | 482 (defun calendar-goto-chinese-date (date &optional noecho) |
483 "Move cursor to Chinese date DATE. | |
92900
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
484 Echo Chinese date unless NOECHO is non-nil." |
13053 | 485 (interactive |
486 (let* ((c (calendar-chinese-from-absolute | |
92900
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
487 (calendar-absolute-from-gregorian (calendar-current-date)))) |
13053 | 488 (cycle (calendar-read |
13281
510f946d1e22
Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13053
diff
changeset
|
489 "Chinese calendar cycle number (>44): " |
92579
8ddfb879916b
Unquote lambda functions. Add autoload cookies to functions formerly
Glenn Morris <rgm@gnu.org>
parents:
92546
diff
changeset
|
490 (lambda (x) (> x 44)) |
13053 | 491 (int-to-string (car c)))) |
492 (year (calendar-read | |
13281
510f946d1e22
Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13053
diff
changeset
|
493 "Year in Chinese cycle (1..60): " |
92579
8ddfb879916b
Unquote lambda functions. Add autoload cookies to functions formerly
Glenn Morris <rgm@gnu.org>
parents:
92546
diff
changeset
|
494 (lambda (x) (and (<= 1 x) (<= x 60))) |
92900
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
495 (int-to-string (cadr c)))) |
13281
510f946d1e22
Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13053
diff
changeset
|
496 (month-list (make-chinese-month-assoc-list |
510f946d1e22
Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13053
diff
changeset
|
497 (chinese-months cycle year))) |
510f946d1e22
Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13053
diff
changeset
|
498 (month (cdr (assoc |
510f946d1e22
Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13053
diff
changeset
|
499 (completing-read "Chinese calendar month: " |
510f946d1e22
Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13053
diff
changeset
|
500 month-list nil t) |
510f946d1e22
Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13053
diff
changeset
|
501 month-list))) |
510f946d1e22
Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13053
diff
changeset
|
502 (last (if (= month |
92900
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
503 (nth 2 |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
504 (calendar-chinese-from-absolute |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
505 (+ 29 |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
506 (calendar-absolute-from-chinese |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
507 (list cycle year month 1)))))) |
13281
510f946d1e22
Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13053
diff
changeset
|
508 30 |
510f946d1e22
Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13053
diff
changeset
|
509 29)) |
510f946d1e22
Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13053
diff
changeset
|
510 (day (calendar-read |
510f946d1e22
Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13053
diff
changeset
|
511 (format "Chinese calendar day (1-%d): " last) |
92579
8ddfb879916b
Unquote lambda functions. Add autoload cookies to functions formerly
Glenn Morris <rgm@gnu.org>
parents:
92546
diff
changeset
|
512 (lambda (x) (and (<= 1 x) (<= x last)))))) |
13053 | 513 (list (list cycle year month day)))) |
514 (calendar-goto-date (calendar-gregorian-from-absolute | |
515 (calendar-absolute-from-chinese date))) | |
516 (or noecho (calendar-print-chinese-date))) | |
517 | |
92614 | 518 (defvar date) |
519 | |
520 ;; To be called from list-sexp-diary-entries, where DATE is bound. | |
92827
02fc7543d146
(generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents:
92660
diff
changeset
|
521 ;;;###diary-autoload |
13053 | 522 (defun diary-chinese-date () |
523 "Chinese calendar equivalent of date diary entry." | |
524 (format "Chinese date: %s" (calendar-chinese-date-string date))) | |
525 | |
14685
496342156d13
Renamed from cal-chinese.el to avoid 14-character limitation.
Karl Heuer <kwzh@gnu.org>
parents:
14169
diff
changeset
|
526 (provide 'cal-china) |
13053 | 527 |
92579
8ddfb879916b
Unquote lambda functions. Add autoload cookies to functions formerly
Glenn Morris <rgm@gnu.org>
parents:
92546
diff
changeset
|
528 ;; arch-tag: 7e5b7e0d-676c-47e3-8696-93e7ea0ab644 |
14685
496342156d13
Renamed from cal-chinese.el to avoid 14-character limitation.
Karl Heuer <kwzh@gnu.org>
parents:
14169
diff
changeset
|
529 ;;; cal-china.el ends here |