Mercurial > emacs
annotate lisp/calendar/cal-china.el @ 93734:0a5160e7009f
Update for rename hebrew-diary-entry-symbol to diary-hebrew-entry-symbol.
author | Glenn Morris <rgm@gnu.org> |
---|---|
date | Sat, 05 Apr 2008 20:21:48 +0000 |
parents | 60b7d8c48c07 |
children | 14357375e115 |
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 | |
93477
92c1edaba777
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93454
diff
changeset
|
30 ;; See calendar.el. |
13053 | 31 |
93477
92c1edaba777
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93454
diff
changeset
|
32 ;; The rules used for the Chinese calendar are those of Baolin Liu |
92c1edaba777
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93454
diff
changeset
|
33 ;; (see L. E. Doggett's article "Calendars" in the Explanatory |
92c1edaba777
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93454
diff
changeset
|
34 ;; Supplement to the Astronomical Almanac, second edition, 1992) for |
92c1edaba777
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93454
diff
changeset
|
35 ;; the calendar as revised at the beginning of the Qing dynasty in |
92c1edaba777
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93454
diff
changeset
|
36 ;; 1644. The nature of the astronomical calculations is such that |
92c1edaba777
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93454
diff
changeset
|
37 ;; precise calculations cannot be made without great expense in time, |
92c1edaba777
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93454
diff
changeset
|
38 ;; so that the calendars produced may not agree perfectly with |
92c1edaba777
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93454
diff
changeset
|
39 ;; published tables--but no two pairs of published tables agree |
92c1edaba777
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93454
diff
changeset
|
40 ;; perfectly either! Liu's rules produce a calendar for 2033 which is |
92c1edaba777
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93454
diff
changeset
|
41 ;; not accepted by all authorities. The date of Chinese New Year is |
92c1edaba777
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93454
diff
changeset
|
42 ;; correct from 1644-2051. |
20462
d179de7ad92e
Add reference to new Calendrical Calculations book.
Paul Eggert <eggert@twinsun.com>
parents:
20215
diff
changeset
|
43 |
92900
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
44 ;; Note to maintainers: |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
45 ;; 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
|
46 ;; value of `chinese-year-cache'. |
13053 | 47 |
92900
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
48 ;;; Code: |
52112
e7d0572ccca5
(displayed-month, displayed-year): Define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
49598
diff
changeset
|
49 |
93220 | 50 (require 'calendar) |
51 (require 'lunar) ; lunar-new-moon-on-or-after | |
52 ;; solar-date-next-longitude brought in by lunar. | |
53 ;;;(require 'solar) | |
93637
60b7d8c48c07
Update for cal-julian name changes.
Glenn Morris <rgm@gnu.org>
parents:
93533
diff
changeset
|
54 ;; calendar-astro-to-absolute and from-absolute are cal-autoloads. |
93220 | 55 ;;;(require 'cal-julian) |
56 | |
13053 | 57 |
92579
8ddfb879916b
Unquote lambda functions. Add autoload cookies to functions formerly
Glenn Morris <rgm@gnu.org>
parents:
92546
diff
changeset
|
58 (defgroup chinese-calendar nil |
8ddfb879916b
Unquote lambda functions. Add autoload cookies to functions formerly
Glenn Morris <rgm@gnu.org>
parents:
92546
diff
changeset
|
59 "Chinese calendar support." |
8ddfb879916b
Unquote lambda functions. Add autoload cookies to functions formerly
Glenn Morris <rgm@gnu.org>
parents:
92546
diff
changeset
|
60 :group 'calendar) |
13053 | 61 |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
38422
diff
changeset
|
62 (defcustom chinese-calendar-time-zone |
13053 | 63 '(if (< year 1928) |
64 (+ 465 (/ 40.0 60.0)) | |
65 480) | |
92660
e64439fb46dc
(chinese-calendar-time-zone, chinese-calendar-daylight-time-offset)
Glenn Morris <rgm@gnu.org>
parents:
92642
diff
changeset
|
66 "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
|
67 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
|
68 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
|
69 :type 'sexp |
17624
7634c31da26e
Add defgroup and use defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
14685
diff
changeset
|
70 :group 'chinese-calendar) |
13053 | 71 |
17624
7634c31da26e
Add defgroup and use defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
14685
diff
changeset
|
72 (defcustom chinese-calendar-location-name "Beijing" |
92546
0ef74aab4b13
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
73 "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
|
74 :type 'string |
7634c31da26e
Add defgroup and use defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
14685
diff
changeset
|
75 :group 'chinese-calendar) |
13053 | 76 |
17624
7634c31da26e
Add defgroup and use defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
14685
diff
changeset
|
77 (defcustom chinese-calendar-daylight-time-offset 0 |
92642 | 78 ;; The correct value is as follows, but the Chinese calendrical |
79 ;; authorities do NOT use DST in determining astronomical events: | |
80 ;; 60 | |
92660
e64439fb46dc
(chinese-calendar-time-zone, chinese-calendar-daylight-time-offset)
Glenn Morris <rgm@gnu.org>
parents:
92642
diff
changeset
|
81 "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
|
82 Default is for no daylight saving time." |
17624
7634c31da26e
Add defgroup and use defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
14685
diff
changeset
|
83 :type 'integer |
7634c31da26e
Add defgroup and use defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
14685
diff
changeset
|
84 :group 'chinese-calendar) |
13053 | 85 |
17624
7634c31da26e
Add defgroup and use defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
14685
diff
changeset
|
86 (defcustom chinese-calendar-standard-time-zone-name |
13053 | 87 '(if (< year 1928) |
88 "PMT" | |
89 "CST") | |
92546
0ef74aab4b13
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
90 "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
|
91 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
|
92 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
|
93 :type 'sexp |
17624
7634c31da26e
Add defgroup and use defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
14685
diff
changeset
|
94 :group 'chinese-calendar) |
13053 | 95 |
17624
7634c31da26e
Add defgroup and use defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
14685
diff
changeset
|
96 (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
|
97 "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
|
98 :type 'string |
7634c31da26e
Add defgroup and use defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
14685
diff
changeset
|
99 :group 'chinese-calendar) |
13053 | 100 |
17624
7634c31da26e
Add defgroup and use defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
14685
diff
changeset
|
101 (defcustom chinese-calendar-daylight-savings-starts nil |
92642 | 102 ;; The correct value is as follows, but the Chinese calendrical |
103 ;; authorities do NOT use DST in determining astronomical events: | |
104 ;; '(cond ((< 1986 year) (calendar-nth-named-day 1 0 4 year 10)) | |
105 ;; ((= 1986 year) '(5 4 1986)) | |
106 ;; (t nil)) | |
92660
e64439fb46dc
(chinese-calendar-time-zone, chinese-calendar-daylight-time-offset)
Glenn Morris <rgm@gnu.org>
parents:
92642
diff
changeset
|
107 "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
|
108 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
|
109 `calendar-daylight-savings-starts'." |
7634c31da26e
Add defgroup and use defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
14685
diff
changeset
|
110 :type 'sexp |
7634c31da26e
Add defgroup and use defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
14685
diff
changeset
|
111 :group 'chinese-calendar) |
13053 | 112 |
17624
7634c31da26e
Add defgroup and use defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
14685
diff
changeset
|
113 (defcustom chinese-calendar-daylight-savings-ends nil |
92642 | 114 ;; The correct value is as follows, but the Chinese calendrical |
115 ;; authorities do NOT use DST in determining astronomical events: | |
116 ;; '(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
|
117 "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
|
118 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
|
119 `calendar-daylight-savings-ends'." |
7634c31da26e
Add defgroup and use defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
14685
diff
changeset
|
120 :type 'sexp |
7634c31da26e
Add defgroup and use defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
14685
diff
changeset
|
121 :group 'chinese-calendar) |
13053 | 122 |
17624
7634c31da26e
Add defgroup and use defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
14685
diff
changeset
|
123 (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
|
124 "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
|
125 Default is for no daylight saving time." |
17624
7634c31da26e
Add defgroup and use defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
14685
diff
changeset
|
126 :type 'integer |
7634c31da26e
Add defgroup and use defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
14685
diff
changeset
|
127 :group 'chinese-calendar) |
13053 | 128 |
17624
7634c31da26e
Add defgroup and use defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
14685
diff
changeset
|
129 (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
|
130 "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
|
131 Default is for no daylight saving time." |
17624
7634c31da26e
Add defgroup and use defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
14685
diff
changeset
|
132 :type 'integer |
7634c31da26e
Add defgroup and use defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
14685
diff
changeset
|
133 :group 'chinese-calendar) |
13053 | 134 |
93090
9144c487a567
(chinese-calendar-celestial-stem, chinese-calendar-terrestrial-branch):
Glenn Morris <rgm@gnu.org>
parents:
92989
diff
changeset
|
135 (defcustom chinese-calendar-celestial-stem |
9144c487a567
(chinese-calendar-celestial-stem, chinese-calendar-terrestrial-branch):
Glenn Morris <rgm@gnu.org>
parents:
92989
diff
changeset
|
136 ["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
|
137 "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
|
138 :group 'chinese-calendar |
9144c487a567
(chinese-calendar-celestial-stem, chinese-calendar-terrestrial-branch):
Glenn Morris <rgm@gnu.org>
parents:
92989
diff
changeset
|
139 :type '(vector (string :tag "Jia") |
9144c487a567
(chinese-calendar-celestial-stem, chinese-calendar-terrestrial-branch):
Glenn Morris <rgm@gnu.org>
parents:
92989
diff
changeset
|
140 (string :tag "Yi") |
9144c487a567
(chinese-calendar-celestial-stem, chinese-calendar-terrestrial-branch):
Glenn Morris <rgm@gnu.org>
parents:
92989
diff
changeset
|
141 (string :tag "Bing") |
9144c487a567
(chinese-calendar-celestial-stem, chinese-calendar-terrestrial-branch):
Glenn Morris <rgm@gnu.org>
parents:
92989
diff
changeset
|
142 (string :tag "Ding") |
9144c487a567
(chinese-calendar-celestial-stem, chinese-calendar-terrestrial-branch):
Glenn Morris <rgm@gnu.org>
parents:
92989
diff
changeset
|
143 (string :tag "Wu") |
9144c487a567
(chinese-calendar-celestial-stem, chinese-calendar-terrestrial-branch):
Glenn Morris <rgm@gnu.org>
parents:
92989
diff
changeset
|
144 (string :tag "Ji") |
9144c487a567
(chinese-calendar-celestial-stem, chinese-calendar-terrestrial-branch):
Glenn Morris <rgm@gnu.org>
parents:
92989
diff
changeset
|
145 (string :tag "Geng") |
9144c487a567
(chinese-calendar-celestial-stem, chinese-calendar-terrestrial-branch):
Glenn Morris <rgm@gnu.org>
parents:
92989
diff
changeset
|
146 (string :tag "Xin") |
9144c487a567
(chinese-calendar-celestial-stem, chinese-calendar-terrestrial-branch):
Glenn Morris <rgm@gnu.org>
parents:
92989
diff
changeset
|
147 (string :tag "Ren") |
9144c487a567
(chinese-calendar-celestial-stem, chinese-calendar-terrestrial-branch):
Glenn Morris <rgm@gnu.org>
parents:
92989
diff
changeset
|
148 (string :tag "Gui"))) |
9144c487a567
(chinese-calendar-celestial-stem, chinese-calendar-terrestrial-branch):
Glenn Morris <rgm@gnu.org>
parents:
92989
diff
changeset
|
149 |
9144c487a567
(chinese-calendar-celestial-stem, chinese-calendar-terrestrial-branch):
Glenn Morris <rgm@gnu.org>
parents:
92989
diff
changeset
|
150 (defcustom chinese-calendar-terrestrial-branch |
9144c487a567
(chinese-calendar-celestial-stem, chinese-calendar-terrestrial-branch):
Glenn Morris <rgm@gnu.org>
parents:
92989
diff
changeset
|
151 ["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
|
152 "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
|
153 :group 'chinese-calendar |
9144c487a567
(chinese-calendar-celestial-stem, chinese-calendar-terrestrial-branch):
Glenn Morris <rgm@gnu.org>
parents:
92989
diff
changeset
|
154 :type '(vector (string :tag "Zi") |
9144c487a567
(chinese-calendar-celestial-stem, chinese-calendar-terrestrial-branch):
Glenn Morris <rgm@gnu.org>
parents:
92989
diff
changeset
|
155 (string :tag "Chou") |
9144c487a567
(chinese-calendar-celestial-stem, chinese-calendar-terrestrial-branch):
Glenn Morris <rgm@gnu.org>
parents:
92989
diff
changeset
|
156 (string :tag "Yin") |
9144c487a567
(chinese-calendar-celestial-stem, chinese-calendar-terrestrial-branch):
Glenn Morris <rgm@gnu.org>
parents:
92989
diff
changeset
|
157 (string :tag "Mao") |
9144c487a567
(chinese-calendar-celestial-stem, chinese-calendar-terrestrial-branch):
Glenn Morris <rgm@gnu.org>
parents:
92989
diff
changeset
|
158 (string :tag "Chen") |
9144c487a567
(chinese-calendar-celestial-stem, chinese-calendar-terrestrial-branch):
Glenn Morris <rgm@gnu.org>
parents:
92989
diff
changeset
|
159 (string :tag "Si") |
9144c487a567
(chinese-calendar-celestial-stem, chinese-calendar-terrestrial-branch):
Glenn Morris <rgm@gnu.org>
parents:
92989
diff
changeset
|
160 (string :tag "Wu") |
9144c487a567
(chinese-calendar-celestial-stem, chinese-calendar-terrestrial-branch):
Glenn Morris <rgm@gnu.org>
parents:
92989
diff
changeset
|
161 (string :tag "Wei") |
9144c487a567
(chinese-calendar-celestial-stem, chinese-calendar-terrestrial-branch):
Glenn Morris <rgm@gnu.org>
parents:
92989
diff
changeset
|
162 (string :tag "Shen") |
9144c487a567
(chinese-calendar-celestial-stem, chinese-calendar-terrestrial-branch):
Glenn Morris <rgm@gnu.org>
parents:
92989
diff
changeset
|
163 (string :tag "You") |
9144c487a567
(chinese-calendar-celestial-stem, chinese-calendar-terrestrial-branch):
Glenn Morris <rgm@gnu.org>
parents:
92989
diff
changeset
|
164 (string :tag "Xu") |
9144c487a567
(chinese-calendar-celestial-stem, chinese-calendar-terrestrial-branch):
Glenn Morris <rgm@gnu.org>
parents:
92989
diff
changeset
|
165 (string :tag "Hai"))) |
9144c487a567
(chinese-calendar-celestial-stem, chinese-calendar-terrestrial-branch):
Glenn Morris <rgm@gnu.org>
parents:
92989
diff
changeset
|
166 |
92579
8ddfb879916b
Unquote lambda functions. Add autoload cookies to functions formerly
Glenn Morris <rgm@gnu.org>
parents:
92546
diff
changeset
|
167 ;;; End of user options. |
8ddfb879916b
Unquote lambda functions. Add autoload cookies to functions formerly
Glenn Morris <rgm@gnu.org>
parents:
92546
diff
changeset
|
168 |
8ddfb879916b
Unquote lambda functions. Add autoload cookies to functions formerly
Glenn Morris <rgm@gnu.org>
parents:
92546
diff
changeset
|
169 |
92900
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
170 (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
|
171 "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
|
172 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
|
173 ..., 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
|
174 (format "%s-%s" |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
175 (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
|
176 (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
|
177 |
13053 | 178 (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
|
179 "Absolute date of first new Zodiac sign on or after absolute date D. |
13053 | 180 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
|
181 (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
|
182 (calendar-time-zone (eval chinese-calendar-time-zone)) ; uses year |
13053 | 183 (calendar-daylight-time-offset |
184 chinese-calendar-daylight-time-offset) | |
185 (calendar-standard-time-zone-name | |
186 chinese-calendar-standard-time-zone-name) | |
187 (calendar-daylight-time-zone-name | |
188 chinese-calendar-daylight-time-zone-name) | |
189 (calendar-calendar-daylight-savings-starts | |
190 chinese-calendar-daylight-savings-starts) | |
191 (calendar-daylight-savings-ends | |
192 chinese-calendar-daylight-savings-ends) | |
193 (calendar-daylight-savings-starts-time | |
194 chinese-calendar-daylight-savings-starts-time) | |
195 (calendar-daylight-savings-ends-time | |
196 chinese-calendar-daylight-savings-ends-time)) | |
197 (floor | |
93637
60b7d8c48c07
Update for cal-julian name changes.
Glenn Morris <rgm@gnu.org>
parents:
93533
diff
changeset
|
198 (calendar-astro-to-absolute |
92900
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
199 (solar-date-next-longitude (calendar-astro-from-absolute d) 30))))) |
13053 | 200 |
201 (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
|
202 "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
|
203 (let* ((year (extract-calendar-year (calendar-gregorian-from-absolute d))) |
13053 | 204 (calendar-time-zone (eval chinese-calendar-time-zone)) |
205 (calendar-daylight-time-offset | |
206 chinese-calendar-daylight-time-offset) | |
207 (calendar-standard-time-zone-name | |
208 chinese-calendar-standard-time-zone-name) | |
209 (calendar-daylight-time-zone-name | |
210 chinese-calendar-daylight-time-zone-name) | |
211 (calendar-calendar-daylight-savings-starts | |
212 chinese-calendar-daylight-savings-starts) | |
213 (calendar-daylight-savings-ends | |
214 chinese-calendar-daylight-savings-ends) | |
215 (calendar-daylight-savings-starts-time | |
216 chinese-calendar-daylight-savings-starts-time) | |
217 (calendar-daylight-savings-ends-time | |
218 chinese-calendar-daylight-savings-ends-time)) | |
219 (floor | |
93637
60b7d8c48c07
Update for cal-julian name changes.
Glenn Morris <rgm@gnu.org>
parents:
93533
diff
changeset
|
220 (calendar-astro-to-absolute |
92900
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
221 (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
|
222 |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
223 (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
|
224 "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
|
225 (if (<= start end) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
226 (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
|
227 (if (<= new-moon end) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
228 (cons new-moon |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
229 (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
|
230 |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
231 (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
|
232 "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
|
233 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
|
234 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
|
235 are never leap months." |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
236 (when list |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
237 (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
|
238 ;; Remaining months. |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
239 (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
|
240 ;; 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
|
241 (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
|
242 (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
|
243 (<= (nth 2 list) |
92900
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
244 (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
|
245 ;; 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
|
246 (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
|
247 (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
|
248 ;; 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
|
249 (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
|
250 |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
251 (defun compute-chinese-year (y) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
252 "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
|
253 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
|
254 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
|
255 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
|
256 (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
|
257 (calendar-absolute-from-gregorian |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
258 (list 12 15 y)))) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
259 (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
|
260 (calendar-absolute-from-gregorian |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
261 (list 12 15 (1- y))))) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
262 next-solstice)) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
263 (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
|
264 (if (= (length list) 12) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
265 ;; 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
|
266 (cons (list 12 (car list)) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
267 (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
|
268 ;; 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
|
269 ;; 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
|
270 (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
|
271 ;; 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
|
272 (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
|
273 (list 12 (cadr list))) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
274 (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
|
275 ;; 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
|
276 (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
|
277 (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
|
278 (nth 2 list)) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
279 ;; 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
|
280 (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
|
281 (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
|
282 ;; 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
|
283 (number-chinese-months (cdr list) 1))))))) |
13053 | 284 |
13281
510f946d1e22
Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13053
diff
changeset
|
285 (defvar chinese-year-cache |
92900
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
286 ;; 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
|
287 ;; 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
|
288 '((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
|
289 (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
|
290 (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
|
291 (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
|
292 (11 730834)) |
cbd4013c57ab
(chinese-year-cache): Change range of years from
Karl Heuer <kwzh@gnu.org>
parents:
20462
diff
changeset
|
293 (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
|
294 (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
|
295 (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
|
296 (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
|
297 (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
|
298 (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
|
299 (11 731927)) |
cbd4013c57ab
(chinese-year-cache): Change range of years from
Karl Heuer <kwzh@gnu.org>
parents:
20462
diff
changeset
|
300 (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
|
301 (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
|
302 (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
|
303 (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
|
304 (11 732665)) |
cbd4013c57ab
(chinese-year-cache): Change range of years from
Karl Heuer <kwzh@gnu.org>
parents:
20462
diff
changeset
|
305 (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
|
306 (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
|
307 (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
|
308 (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
|
309 (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
|
310 (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
|
311 (11 733757)) |
cbd4013c57ab
(chinese-year-cache): Change range of years from
Karl Heuer <kwzh@gnu.org>
parents:
20462
diff
changeset
|
312 (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
|
313 (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
|
314 (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
|
315 (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
|
316 (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
|
317 (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
|
318 (11 734850)) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
319 (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
|
320 (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
|
321 (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
|
322 (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
|
323 (11 735589)) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
324 (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
|
325 (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
|
326 (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
|
327 (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
|
328 (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
|
329 (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
|
330 (11 736681)) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
331 (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
|
332 (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
|
333 (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
|
334 (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
|
335 (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
|
336 (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
|
337 (11 737774))) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
338 "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
|
339 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
|
340 |
510f946d1e22
Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13053
diff
changeset
|
341 (defun chinese-year (y) |
510f946d1e22
Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13053
diff
changeset
|
342 "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
|
343 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
|
344 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
|
345 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
|
346 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
|
347 (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
|
348 (or list |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
349 (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
|
350 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
|
351 (list (cons y list))))) |
13281
510f946d1e22
Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13053
diff
changeset
|
352 list)) |
510f946d1e22
Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13053
diff
changeset
|
353 |
92900
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
354 ;; Maintainer use. |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
355 (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
|
356 "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
|
357 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
|
358 (setq year (- year 10)) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
359 (let (chinese-year-cache end) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
360 (save-excursion |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
361 (insert "'(") |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
362 (dotimes (n 21) |
93533 | 363 (princ (cons year (compute-chinese-year year)) (current-buffer)) |
364 (insert (if (= n 20) ")" "\n")) | |
365 (setq year (1+ year))) | |
92900
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
366 (setq end (point))) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
367 (save-excursion |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
368 ;; fill-column -/+ 5. |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
369 (while (and (< (point) end) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
370 (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
|
371 (delete-char 1) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
372 (insert "\n"))) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
373 (indent-region (point) end))) |
13281
510f946d1e22
Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13053
diff
changeset
|
374 |
13053 | 375 (defun calendar-absolute-from-chinese (date) |
376 "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
|
377 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
|
378 Sunday, December 31, 1 BC is imaginary." |
13053 | 379 (let* ((cycle (car date)) |
92900
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
380 (year (cadr date)) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
381 (month (nth 2 date)) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
382 (day (nth 3 date)) |
92642 | 383 (g-year (+ (* (1- cycle) 60) ; years in prior cycles |
384 (1- year) ; prior years this cycle | |
385 -2636))) ; years before absolute date 0 | |
386 (+ (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
|
387 (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
|
388 (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
|
389 (chinese-year g-year)) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
390 (chinese-year (1+ g-year)))))))) |
13053 | 391 |
392 (defun calendar-chinese-from-absolute (date) | |
393 "Compute Chinese date (cycle year month day) corresponding to absolute DATE. | |
394 The absolute date is the number of days elapsed since the (imaginary) | |
395 Gregorian date Sunday, December 31, 1 BC." | |
13281
510f946d1e22
Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13053
diff
changeset
|
396 (let* ((g-year (extract-calendar-year |
510f946d1e22
Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13053
diff
changeset
|
397 (calendar-gregorian-from-absolute date))) |
13574
c5d4269e17d9
Minor fixes.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13306
diff
changeset
|
398 (c-year (+ g-year 2695)) |
13281
510f946d1e22
Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13053
diff
changeset
|
399 (list (append (chinese-year (1- g-year)) |
510f946d1e22
Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13053
diff
changeset
|
400 (chinese-year g-year) |
510f946d1e22
Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13053
diff
changeset
|
401 (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
|
402 (while (<= (cadr (cadr list)) date) |
92642 | 403 ;; The first month on the list is in Chinese year c-year. |
404 ;; 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
|
405 (if (= 1 (caar (cdr list))) |
92642 | 406 ;; 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
|
407 (setq c-year (1+ c-year))) |
92642 | 408 ;; ...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
|
409 (setq list (cdr list))) |
13574
c5d4269e17d9
Minor fixes.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13306
diff
changeset
|
410 (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
|
411 ;; 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
|
412 (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
|
413 (caar list) |
4151ef80cb37
(number-chinese-months, calendar-chinese-from-absolute): Use nth, caar.
Glenn Morris <rgm@gnu.org>
parents:
92900
diff
changeset
|
414 (1+ (- date (cadr (car list))))))) |
13053 | 415 |
92900
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
416 ;; Bound in generate-calendar. |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
417 (defvar displayed-month) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
418 (defvar displayed-year) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
419 |
92827
02fc7543d146
(generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents:
92660
diff
changeset
|
420 ;;;###holiday-autoload |
13053 | 421 (defun holiday-chinese-new-year () |
93453
22b3710e206a
(holiday-chinese-new-year): Doc fix and comment.
Glenn Morris <rgm@gnu.org>
parents:
93220
diff
changeset
|
422 "Date of Chinese New Year, if visible in calendar. |
22b3710e206a
(holiday-chinese-new-year): Doc fix and comment.
Glenn Morris <rgm@gnu.org>
parents:
93220
diff
changeset
|
423 Returns (((MONTH DAY YEAR) TEXT)), where the date is Gregorian." |
13053 | 424 (let ((m displayed-month) |
93523
aa0e26f1d3ae
(holiday-chinese-new-year): Use a single let.
Glenn Morris <rgm@gnu.org>
parents:
93477
diff
changeset
|
425 (y displayed-year) |
aa0e26f1d3ae
(holiday-chinese-new-year): Use a single let.
Glenn Morris <rgm@gnu.org>
parents:
93477
diff
changeset
|
426 chinese-new-year) |
93453
22b3710e206a
(holiday-chinese-new-year): Doc fix and comment.
Glenn Morris <rgm@gnu.org>
parents:
93220
diff
changeset
|
427 ;; In the Gregorian calendar, CNY falls between Jan 21 and Feb 20. |
22b3710e206a
(holiday-chinese-new-year): Doc fix and comment.
Glenn Morris <rgm@gnu.org>
parents:
93220
diff
changeset
|
428 ;; Jan is visible if displayed-month = 12, 1, 2; Feb if d-m = 1, 2, 3. |
22b3710e206a
(holiday-chinese-new-year): Doc fix and comment.
Glenn Morris <rgm@gnu.org>
parents:
93220
diff
changeset
|
429 ;; If we shift the calendar forward one month, we can do a |
93454 | 430 ;; one-sided test, namely: d-m <= 4 means CNY might be visible. |
93453
22b3710e206a
(holiday-chinese-new-year): Doc fix and comment.
Glenn Morris <rgm@gnu.org>
parents:
93220
diff
changeset
|
431 (increment-calendar-month m y 1) ; shift forward a month |
93523
aa0e26f1d3ae
(holiday-chinese-new-year): Use a single let.
Glenn Morris <rgm@gnu.org>
parents:
93477
diff
changeset
|
432 (and (< m 5) |
aa0e26f1d3ae
(holiday-chinese-new-year): Use a single let.
Glenn Morris <rgm@gnu.org>
parents:
93477
diff
changeset
|
433 (calendar-date-is-visible-p (setq chinese-new-year |
aa0e26f1d3ae
(holiday-chinese-new-year): Use a single let.
Glenn Morris <rgm@gnu.org>
parents:
93477
diff
changeset
|
434 (calendar-gregorian-from-absolute |
aa0e26f1d3ae
(holiday-chinese-new-year): Use a single let.
Glenn Morris <rgm@gnu.org>
parents:
93477
diff
changeset
|
435 (cadr (assoc 1 (chinese-year y)))))) |
aa0e26f1d3ae
(holiday-chinese-new-year): Use a single let.
Glenn Morris <rgm@gnu.org>
parents:
93477
diff
changeset
|
436 (list |
aa0e26f1d3ae
(holiday-chinese-new-year): Use a single let.
Glenn Morris <rgm@gnu.org>
parents:
93477
diff
changeset
|
437 (list chinese-new-year |
aa0e26f1d3ae
(holiday-chinese-new-year): Use a single let.
Glenn Morris <rgm@gnu.org>
parents:
93477
diff
changeset
|
438 (format "Chinese New Year (%s)" |
aa0e26f1d3ae
(holiday-chinese-new-year): Use a single let.
Glenn Morris <rgm@gnu.org>
parents:
93477
diff
changeset
|
439 (calendar-chinese-sexagesimal-name (+ y 57)))))))) |
13053 | 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-chinese-date-string (&optional date) |
443 "String of Chinese date of Gregorian DATE. | |
444 Defaults to today's date if DATE is not given." | |
445 (let* ((a-date (calendar-absolute-from-gregorian | |
446 (or date (calendar-current-date)))) | |
447 (c-date (calendar-chinese-from-absolute a-date)) | |
448 (cycle (car c-date)) | |
92900
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
449 (year (cadr c-date)) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
450 (month (nth 2 c-date)) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
451 (day (nth 3 c-date)) |
13053 | 452 (this-month (calendar-absolute-from-chinese |
453 (list cycle year month 1))) | |
454 (next-month (calendar-absolute-from-chinese | |
13283
f8658d1ca0f2
Various fixes and simplifications.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13281
diff
changeset
|
455 (list (if (= year 60) (1+ cycle) cycle) |
f8658d1ca0f2
Various fixes and simplifications.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13281
diff
changeset
|
456 (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
|
457 ;; 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
|
458 ;; 12 instead of 0. |
130c0da046a4
(calendar-chinese-from-absolute, calendar-chinese-date-string): Expand
Glenn Morris <rgm@gnu.org>
parents:
92967
diff
changeset
|
459 (1+ (mod (floor month) 12)) |
13283
f8658d1ca0f2
Various fixes and simplifications.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13281
diff
changeset
|
460 1))) |
13281
510f946d1e22
Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13053
diff
changeset
|
461 (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
|
462 (format "Cycle %s, year %s (%s), %smonth %s%s, day %s (%s)" |
13053 | 463 cycle |
13675
280cee006df8
(calendar-chinese-sexagesimal-name): Renamed from
Paul Eggert <eggert@twinsun.com>
parents:
13574
diff
changeset
|
464 year (calendar-chinese-sexagesimal-name year) |
13053 | 465 (if (not (integerp month)) |
466 "second " | |
467 (if (< 30 (- next-month this-month)) | |
468 "first " | |
469 "")) | |
13281
510f946d1e22
Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13053
diff
changeset
|
470 (floor month) |
13306
77d8e407592e
Fix the way the sexagisimal names are calculated.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13284
diff
changeset
|
471 (if (integerp month) |
13675
280cee006df8
(calendar-chinese-sexagesimal-name): Renamed from
Paul Eggert <eggert@twinsun.com>
parents:
13574
diff
changeset
|
472 (format " (%s)" (calendar-chinese-sexagesimal-name |
20215
13b173216a3d
(calendar-chinese-date-string): Fix month name.
Karl Heuer <kwzh@gnu.org>
parents:
19903
diff
changeset
|
473 (+ (* 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
|
474 "") |
13675
280cee006df8
(calendar-chinese-sexagesimal-name): Renamed from
Paul Eggert <eggert@twinsun.com>
parents:
13574
diff
changeset
|
475 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
|
476 |
92827
02fc7543d146
(generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents:
92660
diff
changeset
|
477 ;;;###cal-autoload |
13053 | 478 (defun calendar-print-chinese-date () |
479 "Show the Chinese date equivalents of date." | |
480 (interactive) | |
481 (message "Computing Chinese date...") | |
482 (message "Chinese date: %s" | |
483 (calendar-chinese-date-string (calendar-cursor-to-date t)))) | |
484 | |
92900
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
485 (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
|
486 "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
|
487 (and l (car l) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
488 (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
|
489 (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
|
490 (append |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
491 (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
|
492 (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
|
493 (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
|
494 (append |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
495 (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
|
496 (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
|
497 (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
|
498 |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
499 (defun chinese-months (c y) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
500 "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
|
501 (memq 1 (append |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
502 (mapcar (lambda (x) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
503 (car x)) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
504 (chinese-year (extract-calendar-year |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
505 (calendar-gregorian-from-absolute |
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 c y 1 1)))))) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
508 (mapcar (lambda (x) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
509 (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
|
510 (chinese-year (extract-calendar-year |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
511 (calendar-gregorian-from-absolute |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
512 (calendar-absolute-from-chinese |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
513 (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
|
514 (if (= y 60) 1 y) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
515 1 1))))))))) |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
516 |
92827
02fc7543d146
(generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents:
92660
diff
changeset
|
517 ;;;###cal-autoload |
13053 | 518 (defun calendar-goto-chinese-date (date &optional noecho) |
519 "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
|
520 Echo Chinese date unless NOECHO is non-nil." |
13053 | 521 (interactive |
522 (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
|
523 (calendar-absolute-from-gregorian (calendar-current-date)))) |
13053 | 524 (cycle (calendar-read |
13281
510f946d1e22
Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13053
diff
changeset
|
525 "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
|
526 (lambda (x) (> x 44)) |
13053 | 527 (int-to-string (car c)))) |
528 (year (calendar-read | |
13281
510f946d1e22
Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13053
diff
changeset
|
529 "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
|
530 (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
|
531 (int-to-string (cadr c)))) |
13281
510f946d1e22
Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13053
diff
changeset
|
532 (month-list (make-chinese-month-assoc-list |
510f946d1e22
Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13053
diff
changeset
|
533 (chinese-months cycle year))) |
510f946d1e22
Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13053
diff
changeset
|
534 (month (cdr (assoc |
510f946d1e22
Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13053
diff
changeset
|
535 (completing-read "Chinese calendar month: " |
510f946d1e22
Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13053
diff
changeset
|
536 month-list nil t) |
510f946d1e22
Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13053
diff
changeset
|
537 month-list))) |
510f946d1e22
Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13053
diff
changeset
|
538 (last (if (= month |
92900
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
539 (nth 2 |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
540 (calendar-chinese-from-absolute |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
541 (+ 29 |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
542 (calendar-absolute-from-chinese |
c6b7fe651716
Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92827
diff
changeset
|
543 (list cycle year month 1)))))) |
13281
510f946d1e22
Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13053
diff
changeset
|
544 30 |
510f946d1e22
Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13053
diff
changeset
|
545 29)) |
510f946d1e22
Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13053
diff
changeset
|
546 (day (calendar-read |
510f946d1e22
Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13053
diff
changeset
|
547 (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
|
548 (lambda (x) (and (<= 1 x) (<= x last)))))) |
13053 | 549 (list (list cycle year month day)))) |
550 (calendar-goto-date (calendar-gregorian-from-absolute | |
551 (calendar-absolute-from-chinese date))) | |
552 (or noecho (calendar-print-chinese-date))) | |
553 | |
92614 | 554 (defvar date) |
555 | |
556 ;; 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
|
557 ;;;###diary-autoload |
13053 | 558 (defun diary-chinese-date () |
559 "Chinese calendar equivalent of date diary entry." | |
560 (format "Chinese date: %s" (calendar-chinese-date-string date))) | |
561 | |
14685
496342156d13
Renamed from cal-chinese.el to avoid 14-character limitation.
Karl Heuer <kwzh@gnu.org>
parents:
14169
diff
changeset
|
562 (provide 'cal-china) |
13053 | 563 |
92579
8ddfb879916b
Unquote lambda functions. Add autoload cookies to functions formerly
Glenn Morris <rgm@gnu.org>
parents:
92546
diff
changeset
|
564 ;; 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
|
565 ;;; cal-china.el ends here |