Mercurial > emacs
annotate lisp/calendar/cal-china.el @ 93164:849abb573acb
(vc-bzr-state): Return 'removed for removed files and
'unregistered for unregistered files.
author | Dan Nicolaescu <dann@ics.uci.edu> |
---|---|
date | Sun, 23 Mar 2008 20:50:52 +0000 |
parents | 9144c487a567 |
children | f59ab0cdc9ba |
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 |
93090
9144c487a567
(chinese-calendar-celestial-stem, chinese-calendar-terrestrial-branch):
Glenn Morris <rgm@gnu.org>
parents:
92989
diff
changeset
|
131 (defcustom chinese-calendar-celestial-stem |
9144c487a567
(chinese-calendar-celestial-stem, chinese-calendar-terrestrial-branch):
Glenn Morris <rgm@gnu.org>
parents:
92989
diff
changeset
|
132 ["Jia" "Yi" "Bing" "Ding" "Wu" "Ji" "Geng" "Xin" "Ren" "Gui"] |
9144c487a567
(chinese-calendar-celestial-stem, chinese-calendar-terrestrial-branch):
Glenn Morris <rgm@gnu.org>
parents:
92989
diff
changeset
|
133 "Prefixes used by `calendar-chinese-sexagesimal-name'." |
9144c487a567
(chinese-calendar-celestial-stem, chinese-calendar-terrestrial-branch):
Glenn Morris <rgm@gnu.org>
parents:
92989
diff
changeset
|
134 :group 'chinese-calendar |
9144c487a567
(chinese-calendar-celestial-stem, chinese-calendar-terrestrial-branch):
Glenn Morris <rgm@gnu.org>
parents:
92989
diff
changeset
|
135 :type '(vector (string :tag "Jia") |
9144c487a567
(chinese-calendar-celestial-stem, chinese-calendar-terrestrial-branch):
Glenn Morris <rgm@gnu.org>
parents:
92989
diff
changeset
|
136 (string :tag "Yi") |
9144c487a567
(chinese-calendar-celestial-stem, chinese-calendar-terrestrial-branch):
Glenn Morris <rgm@gnu.org>
parents:
92989
diff
changeset
|
137 (string :tag "Bing") |
9144c487a567
(chinese-calendar-celestial-stem, chinese-calendar-terrestrial-branch):
Glenn Morris <rgm@gnu.org>
parents:
92989
diff
changeset
|
138 (string :tag "Ding") |
9144c487a567
(chinese-calendar-celestial-stem, chinese-calendar-terrestrial-branch):
Glenn Morris <rgm@gnu.org>
parents:
92989
diff
changeset
|
139 (string :tag "Wu") |
9144c487a567
(chinese-calendar-celestial-stem, chinese-calendar-terrestrial-branch):
Glenn Morris <rgm@gnu.org>
parents:
92989
diff
changeset
|
140 (string :tag "Ji") |
9144c487a567
(chinese-calendar-celestial-stem, chinese-calendar-terrestrial-branch):
Glenn Morris <rgm@gnu.org>
parents:
92989
diff
changeset
|
141 (string :tag "Geng") |
9144c487a567
(chinese-calendar-celestial-stem, chinese-calendar-terrestrial-branch):
Glenn Morris <rgm@gnu.org>
parents:
92989
diff
changeset
|
142 (string :tag "Xin") |
9144c487a567
(chinese-calendar-celestial-stem, chinese-calendar-terrestrial-branch):
Glenn Morris <rgm@gnu.org>
parents:
92989
diff
changeset
|
143 (string :tag "Ren") |
9144c487a567
(chinese-calendar-celestial-stem, chinese-calendar-terrestrial-branch):
Glenn Morris <rgm@gnu.org>
parents:
92989
diff
changeset
|
144 (string :tag "Gui"))) |
9144c487a567
(chinese-calendar-celestial-stem, chinese-calendar-terrestrial-branch):
Glenn Morris <rgm@gnu.org>
parents:
92989
diff
changeset
|
145 |
9144c487a567
(chinese-calendar-celestial-stem, chinese-calendar-terrestrial-branch):
Glenn Morris <rgm@gnu.org>
parents:
92989
diff
changeset
|
146 (defcustom chinese-calendar-terrestrial-branch |
9144c487a567
(chinese-calendar-celestial-stem, chinese-calendar-terrestrial-branch):
Glenn Morris <rgm@gnu.org>
parents:
92989
diff
changeset
|
147 ["Zi" "Chou" "Yin" "Mao" "Chen" "Si" "Wu" "Wei" "Shen" "You" "Xu" "Hai"] |
9144c487a567
(chinese-calendar-celestial-stem, chinese-calendar-terrestrial-branch):
Glenn Morris <rgm@gnu.org>
parents:
92989
diff
changeset
|
148 "Suffixes used by `calendar-chinese-sexagesimal-name'." |
9144c487a567
(chinese-calendar-celestial-stem, chinese-calendar-terrestrial-branch):
Glenn Morris <rgm@gnu.org>
parents:
92989
diff
changeset
|
149 :group 'chinese-calendar |
9144c487a567
(chinese-calendar-celestial-stem, chinese-calendar-terrestrial-branch):
Glenn Morris <rgm@gnu.org>
parents:
92989
diff
changeset
|
150 :type '(vector (string :tag "Zi") |
9144c487a567
(chinese-calendar-celestial-stem, chinese-calendar-terrestrial-branch):
Glenn Morris <rgm@gnu.org>
parents:
92989
diff
changeset
|
151 (string :tag "Chou") |
9144c487a567
(chinese-calendar-celestial-stem, chinese-calendar-terrestrial-branch):
Glenn Morris <rgm@gnu.org>
parents:
92989
diff
changeset
|
152 (string :tag "Yin") |
9144c487a567
(chinese-calendar-celestial-stem, chinese-calendar-terrestrial-branch):
Glenn Morris <rgm@gnu.org>
parents:
92989
diff
changeset
|
153 (string :tag "Mao") |
9144c487a567
(chinese-calendar-celestial-stem, chinese-calendar-terrestrial-branch):
Glenn Morris <rgm@gnu.org>
parents:
92989
diff
changeset
|
154 (string :tag "Chen") |
9144c487a567
(chinese-calendar-celestial-stem, chinese-calendar-terrestrial-branch):
Glenn Morris <rgm@gnu.org>
parents:
92989
diff
changeset
|
155 (string :tag "Si") |
9144c487a567
(chinese-calendar-celestial-stem, chinese-calendar-terrestrial-branch):
Glenn Morris <rgm@gnu.org>
parents:
92989
diff
changeset
|
156 (string :tag "Wu") |
9144c487a567
(chinese-calendar-celestial-stem, chinese-calendar-terrestrial-branch):
Glenn Morris <rgm@gnu.org>
parents:
92989
diff
changeset
|
157 (string :tag "Wei") |
9144c487a567
(chinese-calendar-celestial-stem, chinese-calendar-terrestrial-branch):
Glenn Morris <rgm@gnu.org>
parents:
92989
diff
changeset
|
158 (string :tag "Shen") |
9144c487a567
(chinese-calendar-celestial-stem, chinese-calendar-terrestrial-branch):
Glenn Morris <rgm@gnu.org>
parents:
92989
diff
changeset
|
159 (string :tag "You") |
9144c487a567
(chinese-calendar-celestial-stem, chinese-calendar-terrestrial-branch):
Glenn Morris <rgm@gnu.org>
parents:
92989
diff
changeset
|
160 (string :tag "Xu") |
9144c487a567
(chinese-calendar-celestial-stem, chinese-calendar-terrestrial-branch):
Glenn Morris <rgm@gnu.org>
parents:
92989
diff
changeset
|
161 (string :tag "Hai"))) |
9144c487a567
(chinese-calendar-celestial-stem, chinese-calendar-terrestrial-branch):
Glenn Morris <rgm@gnu.org>
parents:
92989
diff
changeset
|
162 |
92579
8ddfb879916b
Unquote lambda functions. Add autoload cookies to functions formerly
Glenn Morris <rgm@gnu.org>
parents:
92546
diff
changeset
|
163 ;;; End of user options. |
8ddfb879916b
Unquote lambda functions. Add autoload cookies to functions formerly
Glenn Morris <rgm@gnu.org>
parents:
92546
diff
changeset
|
164 |
8ddfb879916b
Unquote lambda functions. Add autoload cookies to functions formerly
Glenn Morris <rgm@gnu.org>
parents:
92546
diff
changeset
|
165 |
92900
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
166 (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
|
167 "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
|
168 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
|
169 ..., 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
|
170 (format "%s-%s" |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
171 (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
|
172 (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
|
173 |
13053 | 174 (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
|
175 "Absolute date of first new Zodiac sign on or after absolute date D. |
13053 | 176 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
|
177 (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
|
178 (calendar-time-zone (eval chinese-calendar-time-zone)) ; uses year |
13053 | 179 (calendar-daylight-time-offset |
180 chinese-calendar-daylight-time-offset) | |
181 (calendar-standard-time-zone-name | |
182 chinese-calendar-standard-time-zone-name) | |
183 (calendar-daylight-time-zone-name | |
184 chinese-calendar-daylight-time-zone-name) | |
185 (calendar-calendar-daylight-savings-starts | |
186 chinese-calendar-daylight-savings-starts) | |
187 (calendar-daylight-savings-ends | |
188 chinese-calendar-daylight-savings-ends) | |
189 (calendar-daylight-savings-starts-time | |
190 chinese-calendar-daylight-savings-starts-time) | |
191 (calendar-daylight-savings-ends-time | |
192 chinese-calendar-daylight-savings-ends-time)) | |
193 (floor | |
194 (calendar-absolute-from-astro | |
92900
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
195 (solar-date-next-longitude (calendar-astro-from-absolute d) 30))))) |
13053 | 196 |
197 (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
|
198 "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
|
199 (let* ((year (extract-calendar-year (calendar-gregorian-from-absolute d))) |
13053 | 200 (calendar-time-zone (eval chinese-calendar-time-zone)) |
201 (calendar-daylight-time-offset | |
202 chinese-calendar-daylight-time-offset) | |
203 (calendar-standard-time-zone-name | |
204 chinese-calendar-standard-time-zone-name) | |
205 (calendar-daylight-time-zone-name | |
206 chinese-calendar-daylight-time-zone-name) | |
207 (calendar-calendar-daylight-savings-starts | |
208 chinese-calendar-daylight-savings-starts) | |
209 (calendar-daylight-savings-ends | |
210 chinese-calendar-daylight-savings-ends) | |
211 (calendar-daylight-savings-starts-time | |
212 chinese-calendar-daylight-savings-starts-time) | |
213 (calendar-daylight-savings-ends-time | |
214 chinese-calendar-daylight-savings-ends-time)) | |
215 (floor | |
216 (calendar-absolute-from-astro | |
92900
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
217 (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
|
218 |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
219 (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
|
220 "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
|
221 (if (<= start end) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
222 (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
|
223 (if (<= new-moon end) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
224 (cons new-moon |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
225 (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
|
226 |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
227 (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
|
228 "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
|
229 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
|
230 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
|
231 are never leap months." |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
232 (when list |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
233 (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
|
234 ;; Remaining months. |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
235 (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
|
236 ;; 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
|
237 (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
|
238 (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
|
239 (<= (nth 2 list) |
92900
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
240 (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
|
241 ;; 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
|
242 (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
|
243 (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
|
244 ;; 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
|
245 (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
|
246 |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
247 (defun compute-chinese-year (y) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
248 "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
|
249 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
|
250 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
|
251 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
|
252 (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
|
253 (calendar-absolute-from-gregorian |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
254 (list 12 15 y)))) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
255 (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
|
256 (calendar-absolute-from-gregorian |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
257 (list 12 15 (1- y))))) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
258 next-solstice)) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
259 (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
|
260 (if (= (length list) 12) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
261 ;; 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
|
262 (cons (list 12 (car list)) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
263 (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
|
264 ;; 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
|
265 ;; 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
|
266 (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
|
267 ;; 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
|
268 (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
|
269 (list 12 (cadr list))) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
270 (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
|
271 ;; 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
|
272 (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
|
273 (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
|
274 (nth 2 list)) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
275 ;; 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
|
276 (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
|
277 (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
|
278 ;; 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
|
279 (number-chinese-months (cdr list) 1))))))) |
13053 | 280 |
13281
510f946d1e22
Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13053
diff
changeset
|
281 (defvar chinese-year-cache |
92900
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
282 ;; 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
|
283 ;; 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
|
284 '((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
|
285 (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
|
286 (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
|
287 (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
|
288 (11 730834)) |
cbd4013c57ab
(chinese-year-cache): Change range of years from
Karl Heuer <kwzh@gnu.org>
parents:
20462
diff
changeset
|
289 (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
|
290 (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
|
291 (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
|
292 (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
|
293 (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
|
294 (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
|
295 (11 731927)) |
cbd4013c57ab
(chinese-year-cache): Change range of years from
Karl Heuer <kwzh@gnu.org>
parents:
20462
diff
changeset
|
296 (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
|
297 (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
|
298 (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
|
299 (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
|
300 (11 732665)) |
cbd4013c57ab
(chinese-year-cache): Change range of years from
Karl Heuer <kwzh@gnu.org>
parents:
20462
diff
changeset
|
301 (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
|
302 (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
|
303 (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
|
304 (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
|
305 (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
|
306 (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
|
307 (11 733757)) |
cbd4013c57ab
(chinese-year-cache): Change range of years from
Karl Heuer <kwzh@gnu.org>
parents:
20462
diff
changeset
|
308 (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
|
309 (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
|
310 (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
|
311 (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
|
312 (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
|
313 (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
|
314 (11 734850)) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
315 (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
|
316 (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
|
317 (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
|
318 (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
|
319 (11 735589)) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
320 (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
|
321 (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
|
322 (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
|
323 (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
|
324 (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
|
325 (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
|
326 (11 736681)) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
327 (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
|
328 (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
|
329 (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
|
330 (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
|
331 (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
|
332 (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
|
333 (11 737774))) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
334 "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
|
335 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
|
336 |
510f946d1e22
Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13053
diff
changeset
|
337 (defun chinese-year (y) |
510f946d1e22
Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13053
diff
changeset
|
338 "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
|
339 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
|
340 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
|
341 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
|
342 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
|
343 (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
|
344 (or list |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
345 (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
|
346 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
|
347 (list (cons y list))))) |
13281
510f946d1e22
Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13053
diff
changeset
|
348 list)) |
510f946d1e22
Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13053
diff
changeset
|
349 |
92900
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
350 ;; Maintainer use. |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
351 (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
|
352 "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
|
353 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
|
354 (setq year (- year 10)) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
355 (let (chinese-year-cache end) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
356 (save-excursion |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
357 (insert "'(") |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
358 (dotimes (n 21) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
359 (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
|
360 (insert (if (= n 20) ")" "\n")) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
361 (setq year (1+ year))) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
362 (setq end (point))) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
363 (save-excursion |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
364 ;; fill-column -/+ 5. |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
365 (while (and (< (point) end) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
366 (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
|
367 (delete-char 1) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
368 (insert "\n"))) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
369 (indent-region (point) end))) |
13281
510f946d1e22
Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13053
diff
changeset
|
370 |
13053 | 371 (defun calendar-absolute-from-chinese (date) |
372 "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
|
373 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
|
374 Sunday, December 31, 1 BC is imaginary." |
13053 | 375 (let* ((cycle (car date)) |
92900
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
376 (year (cadr date)) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
377 (month (nth 2 date)) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
378 (day (nth 3 date)) |
92642 | 379 (g-year (+ (* (1- cycle) 60) ; years in prior cycles |
380 (1- year) ; prior years this cycle | |
381 -2636))) ; years before absolute date 0 | |
382 (+ (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
|
383 (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
|
384 (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
|
385 (chinese-year g-year)) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
386 (chinese-year (1+ g-year)))))))) |
13053 | 387 |
388 (defun calendar-chinese-from-absolute (date) | |
389 "Compute Chinese date (cycle year month day) corresponding to absolute DATE. | |
390 The absolute date is the number of days elapsed since the (imaginary) | |
391 Gregorian date Sunday, December 31, 1 BC." | |
13281
510f946d1e22
Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13053
diff
changeset
|
392 (let* ((g-year (extract-calendar-year |
510f946d1e22
Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13053
diff
changeset
|
393 (calendar-gregorian-from-absolute date))) |
13574
c5d4269e17d9
Minor fixes.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13306
diff
changeset
|
394 (c-year (+ g-year 2695)) |
13281
510f946d1e22
Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13053
diff
changeset
|
395 (list (append (chinese-year (1- g-year)) |
510f946d1e22
Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13053
diff
changeset
|
396 (chinese-year g-year) |
510f946d1e22
Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13053
diff
changeset
|
397 (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
|
398 (while (<= (cadr (cadr list)) date) |
92642 | 399 ;; The first month on the list is in Chinese year c-year. |
400 ;; 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
|
401 (if (= 1 (caar (cdr list))) |
92642 | 402 ;; 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
|
403 (setq c-year (1+ c-year))) |
92642 | 404 ;; ...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
|
405 (setq list (cdr list))) |
13574
c5d4269e17d9
Minor fixes.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13306
diff
changeset
|
406 (list (/ (1- c-year) 60) |
92989
130c0da046a4
(calendar-chinese-from-absolute, calendar-chinese-date-string): Expand
Glenn Morris <rgm@gnu.org>
parents:
92967
diff
changeset
|
407 ;; Remainder of c-year/60 with 60 instead of 0. |
130c0da046a4
(calendar-chinese-from-absolute, calendar-chinese-date-string): Expand
Glenn Morris <rgm@gnu.org>
parents:
92967
diff
changeset
|
408 (1+ (mod (1- c-year) 60)) |
92967
4151ef80cb37
(number-chinese-months, calendar-chinese-from-absolute): Use nth, caar.
Glenn Morris <rgm@gnu.org>
parents:
92900
diff
changeset
|
409 (caar list) |
4151ef80cb37
(number-chinese-months, calendar-chinese-from-absolute): Use nth, caar.
Glenn Morris <rgm@gnu.org>
parents:
92900
diff
changeset
|
410 (1+ (- date (cadr (car list))))))) |
13053 | 411 |
92900
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
412 ;; Bound in generate-calendar. |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
413 (defvar displayed-month) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
414 (defvar displayed-year) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
415 |
92827
02fc7543d146
(generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents:
92660
diff
changeset
|
416 ;;;###holiday-autoload |
13053 | 417 (defun holiday-chinese-new-year () |
418 "Date of Chinese New Year." | |
419 (let ((m displayed-month) | |
420 (y displayed-year)) | |
421 (increment-calendar-month m y 1) | |
422 (if (< m 5) | |
423 (let ((chinese-new-year | |
424 (calendar-gregorian-from-absolute | |
92900
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
425 (cadr (assoc 1 (chinese-year y)))))) |
13053 | 426 (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
|
427 (list |
77d8e407592e
Fix the way the sexagisimal names are calculated.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13284
diff
changeset
|
428 (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
|
429 (format "Chinese New Year (%s)" |
13675
280cee006df8
(calendar-chinese-sexagesimal-name): Renamed from
Paul Eggert <eggert@twinsun.com>
parents:
13574
diff
changeset
|
430 (calendar-chinese-sexagesimal-name (+ y 57)))))))))) |
13053 | 431 |
92827
02fc7543d146
(generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents:
92660
diff
changeset
|
432 ;;;###cal-autoload |
13053 | 433 (defun calendar-chinese-date-string (&optional date) |
434 "String of Chinese date of Gregorian DATE. | |
435 Defaults to today's date if DATE is not given." | |
436 (let* ((a-date (calendar-absolute-from-gregorian | |
437 (or date (calendar-current-date)))) | |
438 (c-date (calendar-chinese-from-absolute a-date)) | |
439 (cycle (car c-date)) | |
92900
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
440 (year (cadr c-date)) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
441 (month (nth 2 c-date)) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
442 (day (nth 3 c-date)) |
13053 | 443 (this-month (calendar-absolute-from-chinese |
444 (list cycle year month 1))) | |
445 (next-month (calendar-absolute-from-chinese | |
13283
f8658d1ca0f2
Various fixes and simplifications.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13281
diff
changeset
|
446 (list (if (= year 60) (1+ cycle) cycle) |
f8658d1ca0f2
Various fixes and simplifications.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13281
diff
changeset
|
447 (if (= (floor month) 12) (1+ year) year) |
92989
130c0da046a4
(calendar-chinese-from-absolute, calendar-chinese-date-string): Expand
Glenn Morris <rgm@gnu.org>
parents:
92967
diff
changeset
|
448 ;; Remainder of (1+(floor month))/12, with |
130c0da046a4
(calendar-chinese-from-absolute, calendar-chinese-date-string): Expand
Glenn Morris <rgm@gnu.org>
parents:
92967
diff
changeset
|
449 ;; 12 instead of 0. |
130c0da046a4
(calendar-chinese-from-absolute, calendar-chinese-date-string): Expand
Glenn Morris <rgm@gnu.org>
parents:
92967
diff
changeset
|
450 (1+ (mod (floor month) 12)) |
13283
f8658d1ca0f2
Various fixes and simplifications.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13281
diff
changeset
|
451 1))) |
13281
510f946d1e22
Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13053
diff
changeset
|
452 (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
|
453 (format "Cycle %s, year %s (%s), %smonth %s%s, day %s (%s)" |
13053 | 454 cycle |
13675
280cee006df8
(calendar-chinese-sexagesimal-name): Renamed from
Paul Eggert <eggert@twinsun.com>
parents:
13574
diff
changeset
|
455 year (calendar-chinese-sexagesimal-name year) |
13053 | 456 (if (not (integerp month)) |
457 "second " | |
458 (if (< 30 (- next-month this-month)) | |
459 "first " | |
460 "")) | |
13281
510f946d1e22
Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13053
diff
changeset
|
461 (floor month) |
13306
77d8e407592e
Fix the way the sexagisimal names are calculated.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13284
diff
changeset
|
462 (if (integerp month) |
13675
280cee006df8
(calendar-chinese-sexagesimal-name): Renamed from
Paul Eggert <eggert@twinsun.com>
parents:
13574
diff
changeset
|
463 (format " (%s)" (calendar-chinese-sexagesimal-name |
20215
13b173216a3d
(calendar-chinese-date-string): Fix month name.
Karl Heuer <kwzh@gnu.org>
parents:
19903
diff
changeset
|
464 (+ (* 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
|
465 "") |
13675
280cee006df8
(calendar-chinese-sexagesimal-name): Renamed from
Paul Eggert <eggert@twinsun.com>
parents:
13574
diff
changeset
|
466 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
|
467 |
92827
02fc7543d146
(generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents:
92660
diff
changeset
|
468 ;;;###cal-autoload |
13053 | 469 (defun calendar-print-chinese-date () |
470 "Show the Chinese date equivalents of date." | |
471 (interactive) | |
472 (message "Computing Chinese date...") | |
473 (message "Chinese date: %s" | |
474 (calendar-chinese-date-string (calendar-cursor-to-date t)))) | |
475 | |
92900
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
476 (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
|
477 "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
|
478 (and l (car l) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
479 (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
|
480 (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
|
481 (append |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
482 (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
|
483 (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
|
484 (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
|
485 (append |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
486 (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
|
487 (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
|
488 (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
|
489 |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
490 (defun chinese-months (c y) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
491 "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
|
492 (memq 1 (append |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
493 (mapcar (lambda (x) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
494 (car x)) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
495 (chinese-year (extract-calendar-year |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
496 (calendar-gregorian-from-absolute |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
497 (calendar-absolute-from-chinese |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
498 (list c y 1 1)))))) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
499 (mapcar (lambda (x) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
500 (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
|
501 (chinese-year (extract-calendar-year |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
502 (calendar-gregorian-from-absolute |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
503 (calendar-absolute-from-chinese |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
504 (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
|
505 (if (= y 60) 1 y) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
506 1 1))))))))) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
507 |
92827
02fc7543d146
(generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents:
92660
diff
changeset
|
508 ;;;###cal-autoload |
13053 | 509 (defun calendar-goto-chinese-date (date &optional noecho) |
510 "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
|
511 Echo Chinese date unless NOECHO is non-nil." |
13053 | 512 (interactive |
513 (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
|
514 (calendar-absolute-from-gregorian (calendar-current-date)))) |
13053 | 515 (cycle (calendar-read |
13281
510f946d1e22
Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13053
diff
changeset
|
516 "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
|
517 (lambda (x) (> x 44)) |
13053 | 518 (int-to-string (car c)))) |
519 (year (calendar-read | |
13281
510f946d1e22
Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13053
diff
changeset
|
520 "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
|
521 (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
|
522 (int-to-string (cadr c)))) |
13281
510f946d1e22
Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13053
diff
changeset
|
523 (month-list (make-chinese-month-assoc-list |
510f946d1e22
Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13053
diff
changeset
|
524 (chinese-months cycle year))) |
510f946d1e22
Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13053
diff
changeset
|
525 (month (cdr (assoc |
510f946d1e22
Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13053
diff
changeset
|
526 (completing-read "Chinese calendar month: " |
510f946d1e22
Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13053
diff
changeset
|
527 month-list nil t) |
510f946d1e22
Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13053
diff
changeset
|
528 month-list))) |
510f946d1e22
Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13053
diff
changeset
|
529 (last (if (= month |
92900
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
530 (nth 2 |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
531 (calendar-chinese-from-absolute |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
532 (+ 29 |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
533 (calendar-absolute-from-chinese |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
534 (list cycle year month 1)))))) |
13281
510f946d1e22
Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13053
diff
changeset
|
535 30 |
510f946d1e22
Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13053
diff
changeset
|
536 29)) |
510f946d1e22
Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13053
diff
changeset
|
537 (day (calendar-read |
510f946d1e22
Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13053
diff
changeset
|
538 (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
|
539 (lambda (x) (and (<= 1 x) (<= x last)))))) |
13053 | 540 (list (list cycle year month day)))) |
541 (calendar-goto-date (calendar-gregorian-from-absolute | |
542 (calendar-absolute-from-chinese date))) | |
543 (or noecho (calendar-print-chinese-date))) | |
544 | |
92614 | 545 (defvar date) |
546 | |
547 ;; 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
|
548 ;;;###diary-autoload |
13053 | 549 (defun diary-chinese-date () |
550 "Chinese calendar equivalent of date diary entry." | |
551 (format "Chinese date: %s" (calendar-chinese-date-string date))) | |
552 | |
14685
496342156d13
Renamed from cal-chinese.el to avoid 14-character limitation.
Karl Heuer <kwzh@gnu.org>
parents:
14169
diff
changeset
|
553 (provide 'cal-china) |
13053 | 554 |
92579
8ddfb879916b
Unquote lambda functions. Add autoload cookies to functions formerly
Glenn Morris <rgm@gnu.org>
parents:
92546
diff
changeset
|
555 ;; 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
|
556 ;;; cal-china.el ends here |