annotate lisp/calendar/cal-china.el @ 112396:e79e716435f4

Make Nextstep port handle multiple screens for resize and move. * nsterm.h (ns_output): Add dont_constrain and zooming. (EmacsView): Add ns_userRect. * nsterm.m (keyDown): If ns_right_alternate_modifier is Qleft, check if ns_alternate_modifier is none. * nsterm.m (x_set_offset, windowDidMove): When calculating y, use first screen, not the window screen. (x_set_window_size): Remove constraints. Calculate origin.y only if zooming is 0 and without referring to a screen. (windowWillResize): Don't modify frameSize. (windowDidBecomeKey, mouseDown): Set dont_constrain to 1. (initFrameFromEmacs): Initialize ns_userRect. (windowShouldZoom): Set zooming to one. Remove all other code. (windowWillUseStandardFrame): Move static ns_userRect to EmacsView. Zero it after restore. (constrainFrameRect): New method for EmacsWindow. (mouseDragged): Always post NSWindowDidResizeNotification after call to windowWillResize.
author Jan D. <jan.h.d@swipnet.se>
date Fri, 21 Jan 2011 15:19:44 +0100
parents ef719132ddfa
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
2
92642
b3055031d5ea Formatting changes only.
Glenn Morris <rgm@gnu.org>
parents: 92614
diff changeset
3 ;; Copyright (C) 1995, 1997, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
112218
376148b31b5e Add 2011 to FSF/AIST copyright years.
Glenn Morris <rgm@gnu.org>
parents: 106815
diff changeset
4 ;; 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
5
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
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
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
8 ;; Keywords: calendar
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
9 ;; Human-Keywords: Chinese calendar, calendar, holidays, diary
110015
280c8ae2476d Add "Package:" file headers to denote built-in packages.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
10 ;; Package: calendar
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
11
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
12 ;; This file is part of GNU Emacs.
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
13
94653
e49abd957e81 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94282
diff changeset
14 ;; GNU Emacs is free software: you can redistribute it and/or modify
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
15 ;; it under the terms of the GNU General Public License as published by
94653
e49abd957e81 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94282
diff changeset
16 ;; the Free Software Foundation, either version 3 of the License, or
e49abd957e81 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94282
diff changeset
17 ;; (at your option) any later version.
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
18
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
19 ;; GNU Emacs is distributed in the hope that it will be useful,
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
20 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
21 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
22 ;; GNU General Public License for more details.
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
23
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
24 ;; You should have received a copy of the GNU General Public License
94653
e49abd957e81 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94282
diff changeset
25 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
26
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
27 ;;; Commentary:
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
28
93477
92c1edaba777 (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93454
diff changeset
29 ;; See calendar.el.
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
30
93477
92c1edaba777 (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93454
diff changeset
31 ;; 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
32 ;; (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
33 ;; Supplement to the Astronomical Almanac, second edition, 1992) for
92c1edaba777 (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93454
diff changeset
34 ;; 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
35 ;; 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
36 ;; 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
37 ;; 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
38 ;; 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
39 ;; 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
40 ;; 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
41 ;; correct from 1644-2051.
20462
d179de7ad92e Add reference to new Calendrical Calculations book.
Paul Eggert <eggert@twinsun.com>
parents: 20215
diff changeset
42
92900
c6b7fe651716 Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents: 92827
diff changeset
43 ;; Note to maintainers:
c6b7fe651716 Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents: 92827
diff changeset
44 ;; 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
45 ;; value of `chinese-year-cache'.
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
46
92900
c6b7fe651716 Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents: 92827
diff changeset
47 ;;; Code:
52112
e7d0572ccca5 (displayed-month, displayed-year): Define for compiler.
Glenn Morris <rgm@gnu.org>
parents: 49598
diff changeset
48
93220
f59ab0cdc9ba Explicitly require calendar.
Glenn Morris <rgm@gnu.org>
parents: 93090
diff changeset
49 (require 'calendar)
f59ab0cdc9ba Explicitly require calendar.
Glenn Morris <rgm@gnu.org>
parents: 93090
diff changeset
50 (require 'lunar) ; lunar-new-moon-on-or-after
f59ab0cdc9ba Explicitly require calendar.
Glenn Morris <rgm@gnu.org>
parents: 93090
diff changeset
51 ;; solar-date-next-longitude brought in by lunar.
f59ab0cdc9ba Explicitly require calendar.
Glenn Morris <rgm@gnu.org>
parents: 93090
diff changeset
52 ;;;(require 'solar)
93637
60b7d8c48c07 Update for cal-julian name changes.
Glenn Morris <rgm@gnu.org>
parents: 93533
diff changeset
53 ;; calendar-astro-to-absolute and from-absolute are cal-autoloads.
93220
f59ab0cdc9ba Explicitly require calendar.
Glenn Morris <rgm@gnu.org>
parents: 93090
diff changeset
54 ;;;(require 'cal-julian)
f59ab0cdc9ba Explicitly require calendar.
Glenn Morris <rgm@gnu.org>
parents: 93090
diff changeset
55
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
56
93739
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
57 (defgroup calendar-chinese nil
92579
8ddfb879916b Unquote lambda functions. Add autoload cookies to functions formerly
Glenn Morris <rgm@gnu.org>
parents: 92546
diff changeset
58 "Chinese calendar support."
93739
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
59 :prefix "calendar-chinese-"
92579
8ddfb879916b Unquote lambda functions. Add autoload cookies to functions formerly
Glenn Morris <rgm@gnu.org>
parents: 92546
diff changeset
60 :group 'calendar)
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
61
94018
2834643ba8a0 (chinese-calendar-time-zone): Mark obsolete name as risky too.
Glenn Morris <rgm@gnu.org>
parents: 93993
diff changeset
62 (define-obsolete-variable-alias 'chinese-calendar-time-zone
2834643ba8a0 (chinese-calendar-time-zone): Mark obsolete name as risky too.
Glenn Morris <rgm@gnu.org>
parents: 93993
diff changeset
63 'calendar-chinese-time-zone "23.1")
2834643ba8a0 (chinese-calendar-time-zone): Mark obsolete name as risky too.
Glenn Morris <rgm@gnu.org>
parents: 93993
diff changeset
64
93739
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
65 (defcustom calendar-chinese-time-zone
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
66 '(if (< year 1928)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
67 (+ 465 (/ 40.0 60.0))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
68 480)
92660
e64439fb46dc (chinese-calendar-time-zone, chinese-calendar-daylight-time-offset)
Glenn Morris <rgm@gnu.org>
parents: 92642
diff changeset
69 "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
70 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
71 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
72 :type 'sexp
93739
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
73 :group 'calendar-chinese)
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
74
93993
5310823a757f (calendar-chinese-time-zone): Mark as risky.
Glenn Morris <rgm@gnu.org>
parents: 93844
diff changeset
75 ;; It gets eval'd.
5310823a757f (calendar-chinese-time-zone): Mark as risky.
Glenn Morris <rgm@gnu.org>
parents: 93844
diff changeset
76 ;;;###autoload
5310823a757f (calendar-chinese-time-zone): Mark as risky.
Glenn Morris <rgm@gnu.org>
parents: 93844
diff changeset
77 (put 'calendar-chinese-time-zone 'risky-local-variable t)
94018
2834643ba8a0 (chinese-calendar-time-zone): Mark obsolete name as risky too.
Glenn Morris <rgm@gnu.org>
parents: 93993
diff changeset
78 ;;;###autoload
2834643ba8a0 (chinese-calendar-time-zone): Mark obsolete name as risky too.
Glenn Morris <rgm@gnu.org>
parents: 93993
diff changeset
79 (put 'chinese-calendar-time-zone 'risky-local-variable t)
93993
5310823a757f (calendar-chinese-time-zone): Mark as risky.
Glenn Morris <rgm@gnu.org>
parents: 93844
diff changeset
80
94018
2834643ba8a0 (chinese-calendar-time-zone): Mark obsolete name as risky too.
Glenn Morris <rgm@gnu.org>
parents: 93993
diff changeset
81
2834643ba8a0 (chinese-calendar-time-zone): Mark obsolete name as risky too.
Glenn Morris <rgm@gnu.org>
parents: 93993
diff changeset
82 (define-obsolete-variable-alias 'chinese-calendar-location-name
2834643ba8a0 (chinese-calendar-time-zone): Mark obsolete name as risky too.
Glenn Morris <rgm@gnu.org>
parents: 93993
diff changeset
83 'calendar-chinese-location-name "23.1")
93739
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
84
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
85 ;; FIXME unused.
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
86 (defcustom calendar-chinese-location-name "Beijing"
92546
0ef74aab4b13 Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents: 79703
diff changeset
87 "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
88 :type 'string
93739
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
89 :group 'calendar-chinese)
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
90
94018
2834643ba8a0 (chinese-calendar-time-zone): Mark obsolete name as risky too.
Glenn Morris <rgm@gnu.org>
parents: 93993
diff changeset
91 (define-obsolete-variable-alias 'chinese-calendar-daylight-time-offset
2834643ba8a0 (chinese-calendar-time-zone): Mark obsolete name as risky too.
Glenn Morris <rgm@gnu.org>
parents: 93993
diff changeset
92 'calendar-chinese-daylight-time-offset "23.1")
93739
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
93
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
94 (defcustom calendar-chinese-daylight-time-offset 0
92642
b3055031d5ea Formatting changes only.
Glenn Morris <rgm@gnu.org>
parents: 92614
diff changeset
95 ;; The correct value is as follows, but the Chinese calendrical
b3055031d5ea Formatting changes only.
Glenn Morris <rgm@gnu.org>
parents: 92614
diff changeset
96 ;; authorities do NOT use DST in determining astronomical events:
b3055031d5ea Formatting changes only.
Glenn Morris <rgm@gnu.org>
parents: 92614
diff changeset
97 ;; 60
92660
e64439fb46dc (chinese-calendar-time-zone, chinese-calendar-daylight-time-offset)
Glenn Morris <rgm@gnu.org>
parents: 92642
diff changeset
98 "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
99 Default is for no daylight saving time."
17624
7634c31da26e Add defgroup and use defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 14685
diff changeset
100 :type 'integer
93739
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
101 :group 'calendar-chinese)
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
102
94018
2834643ba8a0 (chinese-calendar-time-zone): Mark obsolete name as risky too.
Glenn Morris <rgm@gnu.org>
parents: 93993
diff changeset
103 (define-obsolete-variable-alias 'chinese-calendar-standard-time-zone-name
2834643ba8a0 (chinese-calendar-time-zone): Mark obsolete name as risky too.
Glenn Morris <rgm@gnu.org>
parents: 93993
diff changeset
104 'calendar-chinese-standard-time-zone-name "23.1")
93739
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
105
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
106 (defcustom calendar-chinese-standard-time-zone-name
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
107 '(if (< year 1928)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
108 "PMT"
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
109 "CST")
92546
0ef74aab4b13 Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents: 79703
diff changeset
110 "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
111 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
112 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
113 :type 'sexp
93739
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
114 :group 'calendar-chinese)
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
115
94018
2834643ba8a0 (chinese-calendar-time-zone): Mark obsolete name as risky too.
Glenn Morris <rgm@gnu.org>
parents: 93993
diff changeset
116 (define-obsolete-variable-alias 'chinese-calendar-daylight-time-zone-name
2834643ba8a0 (chinese-calendar-time-zone): Mark obsolete name as risky too.
Glenn Morris <rgm@gnu.org>
parents: 93993
diff changeset
117 'calendar-chinese-daylight-time-zone-name "23.1")
93739
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
118
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
119 (defcustom calendar-chinese-daylight-time-zone-name "CDT"
92546
0ef74aab4b13 Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents: 79703
diff changeset
120 "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
121 :type 'string
93739
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
122 :group 'calendar-chinese)
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
123
94018
2834643ba8a0 (chinese-calendar-time-zone): Mark obsolete name as risky too.
Glenn Morris <rgm@gnu.org>
parents: 93993
diff changeset
124 (define-obsolete-variable-alias 'chinese-calendar-daylight-savings-starts
2834643ba8a0 (chinese-calendar-time-zone): Mark obsolete name as risky too.
Glenn Morris <rgm@gnu.org>
parents: 93993
diff changeset
125 'calendar-chinese-daylight-saving-start "23.1")
93739
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
126
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
127 (defcustom calendar-chinese-daylight-saving-start nil
92642
b3055031d5ea Formatting changes only.
Glenn Morris <rgm@gnu.org>
parents: 92614
diff changeset
128 ;; The correct value is as follows, but the Chinese calendrical
b3055031d5ea Formatting changes only.
Glenn Morris <rgm@gnu.org>
parents: 92614
diff changeset
129 ;; authorities do NOT use DST in determining astronomical events:
b3055031d5ea Formatting changes only.
Glenn Morris <rgm@gnu.org>
parents: 92614
diff changeset
130 ;; '(cond ((< 1986 year) (calendar-nth-named-day 1 0 4 year 10))
b3055031d5ea Formatting changes only.
Glenn Morris <rgm@gnu.org>
parents: 92614
diff changeset
131 ;; ((= 1986 year) '(5 4 1986))
b3055031d5ea Formatting changes only.
Glenn Morris <rgm@gnu.org>
parents: 92614
diff changeset
132 ;; (t nil))
92660
e64439fb46dc (chinese-calendar-time-zone, chinese-calendar-daylight-time-offset)
Glenn Morris <rgm@gnu.org>
parents: 92642
diff changeset
133 "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
134 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
135 `calendar-daylight-savings-starts'."
7634c31da26e Add defgroup and use defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 14685
diff changeset
136 :type 'sexp
93739
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
137 :group 'calendar-chinese)
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
138
94018
2834643ba8a0 (chinese-calendar-time-zone): Mark obsolete name as risky too.
Glenn Morris <rgm@gnu.org>
parents: 93993
diff changeset
139 (define-obsolete-variable-alias 'chinese-calendar-daylight-savings-ends
2834643ba8a0 (chinese-calendar-time-zone): Mark obsolete name as risky too.
Glenn Morris <rgm@gnu.org>
parents: 93993
diff changeset
140 'calendar-chinese-daylight-saving-end "23.1")
93739
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
141
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
142 (defcustom calendar-chinese-daylight-saving-end nil
92642
b3055031d5ea Formatting changes only.
Glenn Morris <rgm@gnu.org>
parents: 92614
diff changeset
143 ;; The correct value is as follows, but the Chinese calendrical
b3055031d5ea Formatting changes only.
Glenn Morris <rgm@gnu.org>
parents: 92614
diff changeset
144 ;; authorities do NOT use DST in determining astronomical events:
b3055031d5ea Formatting changes only.
Glenn Morris <rgm@gnu.org>
parents: 92614
diff changeset
145 ;; '(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
146 "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
147 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
148 `calendar-daylight-savings-ends'."
7634c31da26e Add defgroup and use defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 14685
diff changeset
149 :type 'sexp
93739
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
150 :group 'calendar-chinese)
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
151
94018
2834643ba8a0 (chinese-calendar-time-zone): Mark obsolete name as risky too.
Glenn Morris <rgm@gnu.org>
parents: 93993
diff changeset
152 (define-obsolete-variable-alias 'chinese-calendar-daylight-savings-starts-time
2834643ba8a0 (chinese-calendar-time-zone): Mark obsolete name as risky too.
Glenn Morris <rgm@gnu.org>
parents: 93993
diff changeset
153 'calendar-chinese-daylight-saving-start-time "23.1")
93739
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
154
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
155 (defcustom calendar-chinese-daylight-saving-start-time 0
92660
e64439fb46dc (chinese-calendar-time-zone, chinese-calendar-daylight-time-offset)
Glenn Morris <rgm@gnu.org>
parents: 92642
diff changeset
156 "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
157 Default is for no daylight saving time."
17624
7634c31da26e Add defgroup and use defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 14685
diff changeset
158 :type 'integer
93739
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
159 :group 'calendar-chinese)
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
160
94018
2834643ba8a0 (chinese-calendar-time-zone): Mark obsolete name as risky too.
Glenn Morris <rgm@gnu.org>
parents: 93993
diff changeset
161 (define-obsolete-variable-alias 'chinese-calendar-daylight-savings-ends-time
2834643ba8a0 (chinese-calendar-time-zone): Mark obsolete name as risky too.
Glenn Morris <rgm@gnu.org>
parents: 93993
diff changeset
162 'calendar-chinese-daylight-saving-end-time "23.1")
93739
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
163
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
164 (defcustom calendar-chinese-daylight-saving-end-time 0
92660
e64439fb46dc (chinese-calendar-time-zone, chinese-calendar-daylight-time-offset)
Glenn Morris <rgm@gnu.org>
parents: 92642
diff changeset
165 "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
166 Default is for no daylight saving time."
17624
7634c31da26e Add defgroup and use defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 14685
diff changeset
167 :type 'integer
93739
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
168 :group 'calendar-chinese)
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
169
94018
2834643ba8a0 (chinese-calendar-time-zone): Mark obsolete name as risky too.
Glenn Morris <rgm@gnu.org>
parents: 93993
diff changeset
170 (define-obsolete-variable-alias 'chinese-calendar-celestial-stem
2834643ba8a0 (chinese-calendar-time-zone): Mark obsolete name as risky too.
Glenn Morris <rgm@gnu.org>
parents: 93993
diff changeset
171 'calendar-chinese-celestial-stem "23.1")
93739
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
172
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
173 (defcustom calendar-chinese-celestial-stem
93090
9144c487a567 (chinese-calendar-celestial-stem, chinese-calendar-terrestrial-branch):
Glenn Morris <rgm@gnu.org>
parents: 92989
diff changeset
174 ["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
175 "Prefixes used by `calendar-chinese-sexagesimal-name'."
93739
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
176 :group 'calendar-chinese
93090
9144c487a567 (chinese-calendar-celestial-stem, chinese-calendar-terrestrial-branch):
Glenn Morris <rgm@gnu.org>
parents: 92989
diff changeset
177 :type '(vector (string :tag "Jia")
9144c487a567 (chinese-calendar-celestial-stem, chinese-calendar-terrestrial-branch):
Glenn Morris <rgm@gnu.org>
parents: 92989
diff changeset
178 (string :tag "Yi")
9144c487a567 (chinese-calendar-celestial-stem, chinese-calendar-terrestrial-branch):
Glenn Morris <rgm@gnu.org>
parents: 92989
diff changeset
179 (string :tag "Bing")
9144c487a567 (chinese-calendar-celestial-stem, chinese-calendar-terrestrial-branch):
Glenn Morris <rgm@gnu.org>
parents: 92989
diff changeset
180 (string :tag "Ding")
9144c487a567 (chinese-calendar-celestial-stem, chinese-calendar-terrestrial-branch):
Glenn Morris <rgm@gnu.org>
parents: 92989
diff changeset
181 (string :tag "Wu")
9144c487a567 (chinese-calendar-celestial-stem, chinese-calendar-terrestrial-branch):
Glenn Morris <rgm@gnu.org>
parents: 92989
diff changeset
182 (string :tag "Ji")
9144c487a567 (chinese-calendar-celestial-stem, chinese-calendar-terrestrial-branch):
Glenn Morris <rgm@gnu.org>
parents: 92989
diff changeset
183 (string :tag "Geng")
9144c487a567 (chinese-calendar-celestial-stem, chinese-calendar-terrestrial-branch):
Glenn Morris <rgm@gnu.org>
parents: 92989
diff changeset
184 (string :tag "Xin")
9144c487a567 (chinese-calendar-celestial-stem, chinese-calendar-terrestrial-branch):
Glenn Morris <rgm@gnu.org>
parents: 92989
diff changeset
185 (string :tag "Ren")
9144c487a567 (chinese-calendar-celestial-stem, chinese-calendar-terrestrial-branch):
Glenn Morris <rgm@gnu.org>
parents: 92989
diff changeset
186 (string :tag "Gui")))
9144c487a567 (chinese-calendar-celestial-stem, chinese-calendar-terrestrial-branch):
Glenn Morris <rgm@gnu.org>
parents: 92989
diff changeset
187
94018
2834643ba8a0 (chinese-calendar-time-zone): Mark obsolete name as risky too.
Glenn Morris <rgm@gnu.org>
parents: 93993
diff changeset
188 (define-obsolete-variable-alias 'chinese-calendar-terrestrial-branch
2834643ba8a0 (chinese-calendar-time-zone): Mark obsolete name as risky too.
Glenn Morris <rgm@gnu.org>
parents: 93993
diff changeset
189 'calendar-chinese-terrestrial-branch "23.1")
93739
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
190
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
191 (defcustom calendar-chinese-terrestrial-branch
93090
9144c487a567 (chinese-calendar-celestial-stem, chinese-calendar-terrestrial-branch):
Glenn Morris <rgm@gnu.org>
parents: 92989
diff changeset
192 ["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
193 "Suffixes used by `calendar-chinese-sexagesimal-name'."
93739
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
194 :group 'calendar-chinese
93090
9144c487a567 (chinese-calendar-celestial-stem, chinese-calendar-terrestrial-branch):
Glenn Morris <rgm@gnu.org>
parents: 92989
diff changeset
195 :type '(vector (string :tag "Zi")
9144c487a567 (chinese-calendar-celestial-stem, chinese-calendar-terrestrial-branch):
Glenn Morris <rgm@gnu.org>
parents: 92989
diff changeset
196 (string :tag "Chou")
9144c487a567 (chinese-calendar-celestial-stem, chinese-calendar-terrestrial-branch):
Glenn Morris <rgm@gnu.org>
parents: 92989
diff changeset
197 (string :tag "Yin")
9144c487a567 (chinese-calendar-celestial-stem, chinese-calendar-terrestrial-branch):
Glenn Morris <rgm@gnu.org>
parents: 92989
diff changeset
198 (string :tag "Mao")
9144c487a567 (chinese-calendar-celestial-stem, chinese-calendar-terrestrial-branch):
Glenn Morris <rgm@gnu.org>
parents: 92989
diff changeset
199 (string :tag "Chen")
9144c487a567 (chinese-calendar-celestial-stem, chinese-calendar-terrestrial-branch):
Glenn Morris <rgm@gnu.org>
parents: 92989
diff changeset
200 (string :tag "Si")
9144c487a567 (chinese-calendar-celestial-stem, chinese-calendar-terrestrial-branch):
Glenn Morris <rgm@gnu.org>
parents: 92989
diff changeset
201 (string :tag "Wu")
9144c487a567 (chinese-calendar-celestial-stem, chinese-calendar-terrestrial-branch):
Glenn Morris <rgm@gnu.org>
parents: 92989
diff changeset
202 (string :tag "Wei")
9144c487a567 (chinese-calendar-celestial-stem, chinese-calendar-terrestrial-branch):
Glenn Morris <rgm@gnu.org>
parents: 92989
diff changeset
203 (string :tag "Shen")
9144c487a567 (chinese-calendar-celestial-stem, chinese-calendar-terrestrial-branch):
Glenn Morris <rgm@gnu.org>
parents: 92989
diff changeset
204 (string :tag "You")
9144c487a567 (chinese-calendar-celestial-stem, chinese-calendar-terrestrial-branch):
Glenn Morris <rgm@gnu.org>
parents: 92989
diff changeset
205 (string :tag "Xu")
9144c487a567 (chinese-calendar-celestial-stem, chinese-calendar-terrestrial-branch):
Glenn Morris <rgm@gnu.org>
parents: 92989
diff changeset
206 (string :tag "Hai")))
9144c487a567 (chinese-calendar-celestial-stem, chinese-calendar-terrestrial-branch):
Glenn Morris <rgm@gnu.org>
parents: 92989
diff changeset
207
92579
8ddfb879916b Unquote lambda functions. Add autoload cookies to functions formerly
Glenn Morris <rgm@gnu.org>
parents: 92546
diff changeset
208 ;;; End of user options.
8ddfb879916b Unquote lambda functions. Add autoload cookies to functions formerly
Glenn Morris <rgm@gnu.org>
parents: 92546
diff changeset
209
8ddfb879916b Unquote lambda functions. Add autoload cookies to functions formerly
Glenn Morris <rgm@gnu.org>
parents: 92546
diff changeset
210
92900
c6b7fe651716 Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents: 92827
diff changeset
211 (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
212 "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
213 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
214 ..., 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
215 (format "%s-%s"
93739
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
216 (aref calendar-chinese-celestial-stem (% (1- n) 10))
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
217 (aref calendar-chinese-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
218
93739
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
219 (defun calendar-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
220 "Absolute date of first new Zodiac sign on or after absolute date D.
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
221 The Zodiac signs begin when the sun's longitude is a multiple of 30 degrees."
93809
3ff2b47de8f2 Update for calendar.el name changes.
Glenn Morris <rgm@gnu.org>
parents: 93779
diff changeset
222 (let* ((year (calendar-extract-year (calendar-gregorian-from-absolute d)))
93739
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
223 (calendar-time-zone (eval calendar-chinese-time-zone)) ; uses year
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
224 (calendar-daylight-time-offset
93739
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
225 calendar-chinese-daylight-time-offset)
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
226 (calendar-standard-time-zone-name
93739
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
227 calendar-chinese-standard-time-zone-name)
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
228 (calendar-daylight-time-zone-name
93739
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
229 calendar-chinese-daylight-time-zone-name)
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
230 (calendar-daylight-savings-starts
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
231 calendar-chinese-daylight-saving-start)
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
232 (calendar-daylight-savings-ends
93739
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
233 calendar-chinese-daylight-saving-end)
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
234 (calendar-daylight-savings-starts-time
93739
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
235 calendar-chinese-daylight-saving-start-time)
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
236 (calendar-daylight-savings-ends-time
93739
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
237 calendar-chinese-daylight-saving-end-time))
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
238 (floor
93637
60b7d8c48c07 Update for cal-julian name changes.
Glenn Morris <rgm@gnu.org>
parents: 93533
diff changeset
239 (calendar-astro-to-absolute
92900
c6b7fe651716 Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents: 92827
diff changeset
240 (solar-date-next-longitude (calendar-astro-from-absolute d) 30)))))
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
241
93739
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
242 (defun calendar-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
243 "Absolute date of first new moon on or after absolute date D."
93809
3ff2b47de8f2 Update for calendar.el name changes.
Glenn Morris <rgm@gnu.org>
parents: 93779
diff changeset
244 (let* ((year (calendar-extract-year (calendar-gregorian-from-absolute d)))
93739
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
245 (calendar-time-zone (eval calendar-chinese-time-zone))
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
246 (calendar-daylight-time-offset
93739
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
247 calendar-chinese-daylight-time-offset)
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
248 (calendar-standard-time-zone-name
93739
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
249 calendar-chinese-standard-time-zone-name)
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
250 (calendar-daylight-time-zone-name
93739
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
251 calendar-chinese-daylight-time-zone-name)
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
252 (calendar-daylight-savings-starts
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
253 calendar-chinese-daylight-saving-start)
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
254 (calendar-daylight-savings-ends
93739
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
255 calendar-chinese-daylight-saving-end)
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
256 (calendar-daylight-savings-starts-time
93739
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
257 calendar-chinese-daylight-saving-start-time)
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
258 (calendar-daylight-savings-ends-time
93739
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
259 calendar-chinese-daylight-saving-end-time))
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
260 (floor
93637
60b7d8c48c07 Update for cal-julian name changes.
Glenn Morris <rgm@gnu.org>
parents: 93533
diff changeset
261 (calendar-astro-to-absolute
92900
c6b7fe651716 Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents: 92827
diff changeset
262 (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
263
93739
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
264 (defun calendar-chinese-month-list (start end)
92900
c6b7fe651716 Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents: 92827
diff changeset
265 "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
266 (if (<= start end)
93739
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
267 (let ((new-moon (calendar-chinese-new-moon-on-or-after start)))
92900
c6b7fe651716 Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents: 92827
diff changeset
268 (if (<= new-moon end)
c6b7fe651716 Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents: 92827
diff changeset
269 (cons new-moon
93739
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
270 (calendar-chinese-month-list (1+ new-moon) end))))))
92900
c6b7fe651716 Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents: 92827
diff changeset
271
93739
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
272 (defun calendar-chinese-number-months (list start)
92900
c6b7fe651716 Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents: 92827
diff changeset
273 "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
274 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
275 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
276 are never leap months."
c6b7fe651716 Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents: 92827
diff changeset
277 (when list
c6b7fe651716 Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents: 92827
diff changeset
278 (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
279 ;; Remaining months.
c6b7fe651716 Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents: 92827
diff changeset
280 (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
281 ;; List is too short for a leap month.
93739
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
282 (calendar-chinese-number-months (cdr list) (1+ start))
92900
c6b7fe651716 Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents: 92827
diff changeset
283 (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
284 (<= (nth 2 list)
93739
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
285 (calendar-chinese-zodiac-sign-on-or-after
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
286 (cadr list))))
92900
c6b7fe651716 Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents: 92827
diff changeset
287 ;; 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
288 (cons (list (+ start 0.5) (cadr list))
93739
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
289 (calendar-chinese-number-months (cddr list) (1+ start)))
92900
c6b7fe651716 Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents: 92827
diff changeset
290 ;; Next month is not a leap month.
93739
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
291 (calendar-chinese-number-months (cdr list) (1+ start)))))))
92900
c6b7fe651716 Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents: 92827
diff changeset
292
93739
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
293 (defun calendar-chinese-compute-year (y)
92900
c6b7fe651716 Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents: 92827
diff changeset
294 "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
295 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
296 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
297 Gregorian year Y-1 to the Chinese month of the solstice of Gregorian year Y."
93739
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
298 (let* ((next-solstice (calendar-chinese-zodiac-sign-on-or-after
92900
c6b7fe651716 Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents: 92827
diff changeset
299 (calendar-absolute-from-gregorian
c6b7fe651716 Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents: 92827
diff changeset
300 (list 12 15 y))))
93739
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
301 (list (calendar-chinese-month-list
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
302 (1+ (calendar-chinese-zodiac-sign-on-or-after
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
303 (calendar-absolute-from-gregorian
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
304 (list 12 15 (1- y)))))
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
305 next-solstice))
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
306 (next-sign (calendar-chinese-zodiac-sign-on-or-after (car list))))
92900
c6b7fe651716 Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents: 92827
diff changeset
307 (if (= (length list) 12)
c6b7fe651716 Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents: 92827
diff changeset
308 ;; 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
309 (cons (list 12 (car list))
93739
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
310 (calendar-chinese-number-months (cdr list) 1))
92900
c6b7fe651716 Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents: 92827
diff changeset
311 ;; 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
312 ;; 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
313 (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
314 ;; 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
315 (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
316 (list 12 (cadr list)))
93739
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
317 (calendar-chinese-number-months (cddr list) 1))
92900
c6b7fe651716 Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents: 92827
diff changeset
318 ;; 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
319 (append (list (list 12 (car list)))
93739
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
320 (if (>= (calendar-chinese-zodiac-sign-on-or-after (cadr list))
92900
c6b7fe651716 Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents: 92827
diff changeset
321 (nth 2 list))
c6b7fe651716 Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents: 92827
diff changeset
322 ;; 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
323 (cons (list 12.5 (cadr list))
93739
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
324 (calendar-chinese-number-months (cddr list) 1))
92900
c6b7fe651716 Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents: 92827
diff changeset
325 ;; Second month on list is not a leap month.
93739
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
326 (calendar-chinese-number-months (cdr list) 1)))))))
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
327
93739
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
328 (defvar calendar-chinese-year-cache
92900
c6b7fe651716 Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents: 92827
diff changeset
329 ;; Maintainers: delete existing value, position point at start of
93739
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
330 ;; empty line, then call M-: (calendar-chinese-year-cache-init N)
92900
c6b7fe651716 Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents: 92827
diff changeset
331 '((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
332 (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
333 (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
334 (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
335 (11 730834))
cbd4013c57ab (chinese-year-cache): Change range of years from
Karl Heuer <kwzh@gnu.org>
parents: 20462
diff changeset
336 (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
337 (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
338 (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
339 (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
340 (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
341 (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
342 (11 731927))
cbd4013c57ab (chinese-year-cache): Change range of years from
Karl Heuer <kwzh@gnu.org>
parents: 20462
diff changeset
343 (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
344 (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
345 (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
346 (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
347 (11 732665))
cbd4013c57ab (chinese-year-cache): Change range of years from
Karl Heuer <kwzh@gnu.org>
parents: 20462
diff changeset
348 (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
349 (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
350 (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
351 (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
352 (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
353 (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
354 (11 733757))
cbd4013c57ab (chinese-year-cache): Change range of years from
Karl Heuer <kwzh@gnu.org>
parents: 20462
diff changeset
355 (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
356 (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
357 (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
358 (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
359 (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
360 (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
361 (11 734850))
c6b7fe651716 Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents: 92827
diff changeset
362 (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
363 (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
364 (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
365 (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
366 (11 735589))
c6b7fe651716 Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents: 92827
diff changeset
367 (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
368 (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
369 (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
370 (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
371 (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
372 (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
373 (11 736681))
c6b7fe651716 Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents: 92827
diff changeset
374 (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
375 (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
376 (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
377 (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
378 (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
379 (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
380 (11 737774)))
c6b7fe651716 Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents: 92827
diff changeset
381 "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
382 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
383
93739
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
384 (defun calendar-chinese-year (y)
13281
510f946d1e22 Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents: 13053
diff changeset
385 "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
386 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
387 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
388 Gregorian year Y-1 to the Chinese month of the solstice of Gregorian year Y.
93739
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
389 The list is cached in `calendar-chinese-year-cache' for further use."
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
390 (let ((list (cdr (assoc y calendar-chinese-year-cache))))
92900
c6b7fe651716 Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents: 92827
diff changeset
391 (or list
93739
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
392 (setq list (calendar-chinese-compute-year y)
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
393 calendar-chinese-year-cache (append calendar-chinese-year-cache
92900
c6b7fe651716 Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents: 92827
diff changeset
394 (list (cons y list)))))
13281
510f946d1e22 Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents: 13053
diff changeset
395 list))
510f946d1e22 Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents: 13053
diff changeset
396
92900
c6b7fe651716 Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents: 92827
diff changeset
397 ;; Maintainer use.
93739
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
398 (defun calendar-chinese-year-cache-init (year)
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
399 "Insert an initialization value for `calendar-chinese-year-cache' after point.
92900
c6b7fe651716 Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents: 92827
diff changeset
400 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
401 (setq year (- year 10))
93739
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
402 (let (calendar-chinese-year-cache end)
92900
c6b7fe651716 Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents: 92827
diff changeset
403 (save-excursion
c6b7fe651716 Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents: 92827
diff changeset
404 (insert "'(")
c6b7fe651716 Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents: 92827
diff changeset
405 (dotimes (n 21)
93739
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
406 (princ (cons year (calendar-chinese-compute-year year))
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
407 (current-buffer))
93533
851deb208446 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 93523
diff changeset
408 (insert (if (= n 20) ")" "\n"))
851deb208446 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 93523
diff changeset
409 (setq year (1+ year)))
92900
c6b7fe651716 Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents: 92827
diff changeset
410 (setq end (point)))
c6b7fe651716 Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents: 92827
diff changeset
411 (save-excursion
c6b7fe651716 Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents: 92827
diff changeset
412 ;; fill-column -/+ 5.
c6b7fe651716 Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents: 92827
diff changeset
413 (while (and (< (point) end)
c6b7fe651716 Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents: 92827
diff changeset
414 (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
415 (delete-char 1)
c6b7fe651716 Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents: 92827
diff changeset
416 (insert "\n")))
c6b7fe651716 Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents: 92827
diff changeset
417 (indent-region (point) end)))
13281
510f946d1e22 Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents: 13053
diff changeset
418
93739
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
419 (defun calendar-chinese-to-absolute (date)
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
420 "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
421 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
422 Sunday, December 31, 1 BC is imaginary."
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
423 (let* ((cycle (car date))
92900
c6b7fe651716 Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents: 92827
diff changeset
424 (year (cadr date))
c6b7fe651716 Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents: 92827
diff changeset
425 (month (nth 2 date))
c6b7fe651716 Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents: 92827
diff changeset
426 (day (nth 3 date))
92642
b3055031d5ea Formatting changes only.
Glenn Morris <rgm@gnu.org>
parents: 92614
diff changeset
427 (g-year (+ (* (1- cycle) 60) ; years in prior cycles
b3055031d5ea Formatting changes only.
Glenn Morris <rgm@gnu.org>
parents: 92614
diff changeset
428 (1- year) ; prior years this cycle
b3055031d5ea Formatting changes only.
Glenn Morris <rgm@gnu.org>
parents: 92614
diff changeset
429 -2636))) ; years before absolute date 0
b3055031d5ea Formatting changes only.
Glenn Morris <rgm@gnu.org>
parents: 92614
diff changeset
430 (+ (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
431 (cadr ; absolute date of start of this month
93739
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
432 (assoc month (append (memq (assoc 1 (calendar-chinese-year g-year))
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
433 (calendar-chinese-year g-year))
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
434 (calendar-chinese-year (1+ g-year))))))))
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
435
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
436 (define-obsolete-function-alias 'calendar-absolute-from-chinese
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
437 'calendar-chinese-to-absolute "23.1")
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
438
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
439 (defun calendar-chinese-from-absolute (date)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
440 "Compute Chinese date (cycle year month day) corresponding to absolute DATE.
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
441 The absolute date is the number of days elapsed since the (imaginary)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
442 Gregorian date Sunday, December 31, 1 BC."
93809
3ff2b47de8f2 Update for calendar.el name changes.
Glenn Morris <rgm@gnu.org>
parents: 93779
diff changeset
443 (let* ((g-year (calendar-extract-year
13281
510f946d1e22 Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents: 13053
diff changeset
444 (calendar-gregorian-from-absolute date)))
13574
c5d4269e17d9 Minor fixes.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents: 13306
diff changeset
445 (c-year (+ g-year 2695))
93739
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
446 (list (append (calendar-chinese-year (1- g-year))
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
447 (calendar-chinese-year g-year)
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
448 (calendar-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
449 (while (<= (cadr (cadr list)) date)
92642
b3055031d5ea Formatting changes only.
Glenn Morris <rgm@gnu.org>
parents: 92614
diff changeset
450 ;; The first month on the list is in Chinese year c-year.
b3055031d5ea Formatting changes only.
Glenn Morris <rgm@gnu.org>
parents: 92614
diff changeset
451 ;; 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
452 (if (= 1 (caar (cdr list)))
92642
b3055031d5ea Formatting changes only.
Glenn Morris <rgm@gnu.org>
parents: 92614
diff changeset
453 ;; 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
454 (setq c-year (1+ c-year)))
92642
b3055031d5ea Formatting changes only.
Glenn Morris <rgm@gnu.org>
parents: 92614
diff changeset
455 ;; ...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
456 (setq list (cdr list)))
13574
c5d4269e17d9 Minor fixes.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents: 13306
diff changeset
457 (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
458 ;; 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
459 (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
460 (caar list)
4151ef80cb37 (number-chinese-months, calendar-chinese-from-absolute): Use nth, caar.
Glenn Morris <rgm@gnu.org>
parents: 92900
diff changeset
461 (1+ (- date (cadr (car list)))))))
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
462
93809
3ff2b47de8f2 Update for calendar.el name changes.
Glenn Morris <rgm@gnu.org>
parents: 93779
diff changeset
463 ;; Bound in calendar-generate.
92900
c6b7fe651716 Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents: 92827
diff changeset
464 (defvar displayed-month)
c6b7fe651716 Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents: 92827
diff changeset
465 (defvar displayed-year)
c6b7fe651716 Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents: 92827
diff changeset
466
92827
02fc7543d146 (generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents: 92660
diff changeset
467 ;;;###holiday-autoload
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
468 (defun holiday-chinese-new-year ()
93453
22b3710e206a (holiday-chinese-new-year): Doc fix and comment.
Glenn Morris <rgm@gnu.org>
parents: 93220
diff changeset
469 "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
470 Returns (((MONTH DAY YEAR) TEXT)), where the date is Gregorian."
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
471 (let ((m displayed-month)
93523
aa0e26f1d3ae (holiday-chinese-new-year): Use a single let.
Glenn Morris <rgm@gnu.org>
parents: 93477
diff changeset
472 (y displayed-year)
aa0e26f1d3ae (holiday-chinese-new-year): Use a single let.
Glenn Morris <rgm@gnu.org>
parents: 93477
diff changeset
473 chinese-new-year)
93453
22b3710e206a (holiday-chinese-new-year): Doc fix and comment.
Glenn Morris <rgm@gnu.org>
parents: 93220
diff changeset
474 ;; 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
475 ;; 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
476 ;; If we shift the calendar forward one month, we can do a
93454
648b1e67e4b5 Fix typo in previous change.
Glenn Morris <rgm@gnu.org>
parents: 93453
diff changeset
477 ;; one-sided test, namely: d-m <= 4 means CNY might be visible.
93809
3ff2b47de8f2 Update for calendar.el name changes.
Glenn Morris <rgm@gnu.org>
parents: 93779
diff changeset
478 (calendar-increment-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
479 (and (< m 5)
93739
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
480 (calendar-date-is-visible-p
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
481 (setq chinese-new-year
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
482 (calendar-gregorian-from-absolute
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
483 (cadr (assoc 1 (calendar-chinese-year y))))))
93523
aa0e26f1d3ae (holiday-chinese-new-year): Use a single let.
Glenn Morris <rgm@gnu.org>
parents: 93477
diff changeset
484 (list
aa0e26f1d3ae (holiday-chinese-new-year): Use a single let.
Glenn Morris <rgm@gnu.org>
parents: 93477
diff changeset
485 (list chinese-new-year
aa0e26f1d3ae (holiday-chinese-new-year): Use a single let.
Glenn Morris <rgm@gnu.org>
parents: 93477
diff changeset
486 (format "Chinese New Year (%s)"
aa0e26f1d3ae (holiday-chinese-new-year): Use a single let.
Glenn Morris <rgm@gnu.org>
parents: 93477
diff changeset
487 (calendar-chinese-sexagesimal-name (+ y 57))))))))
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
488
94282
70cc209bf336 (holiday-chinese-qingming, holiday-chinese-winter-solstice)
Glenn Morris <rgm@gnu.org>
parents: 94018
diff changeset
489 ;;;###holiday-autoload
70cc209bf336 (holiday-chinese-qingming, holiday-chinese-winter-solstice)
Glenn Morris <rgm@gnu.org>
parents: 94018
diff changeset
490 (defun holiday-chinese-qingming ()
70cc209bf336 (holiday-chinese-qingming, holiday-chinese-winter-solstice)
Glenn Morris <rgm@gnu.org>
parents: 94018
diff changeset
491 "Date of Chinese Qingming Festival, if visible in calendar.
70cc209bf336 (holiday-chinese-qingming, holiday-chinese-winter-solstice)
Glenn Morris <rgm@gnu.org>
parents: 94018
diff changeset
492 Returns (((MONTH DAY YEAR) TEXT)), where the date is Gregorian."
70cc209bf336 (holiday-chinese-qingming, holiday-chinese-winter-solstice)
Glenn Morris <rgm@gnu.org>
parents: 94018
diff changeset
493 (when (memq displayed-month '(3 4 5)) ; is April visible?
70cc209bf336 (holiday-chinese-qingming, holiday-chinese-winter-solstice)
Glenn Morris <rgm@gnu.org>
parents: 94018
diff changeset
494 (list (list (calendar-gregorian-from-absolute
70cc209bf336 (holiday-chinese-qingming, holiday-chinese-winter-solstice)
Glenn Morris <rgm@gnu.org>
parents: 94018
diff changeset
495 ;; 15 days after Vernal Equinox.
70cc209bf336 (holiday-chinese-qingming, holiday-chinese-winter-solstice)
Glenn Morris <rgm@gnu.org>
parents: 94018
diff changeset
496 (+ 15
70cc209bf336 (holiday-chinese-qingming, holiday-chinese-winter-solstice)
Glenn Morris <rgm@gnu.org>
parents: 94018
diff changeset
497 (calendar-chinese-zodiac-sign-on-or-after
70cc209bf336 (holiday-chinese-qingming, holiday-chinese-winter-solstice)
Glenn Morris <rgm@gnu.org>
parents: 94018
diff changeset
498 (calendar-absolute-from-gregorian
70cc209bf336 (holiday-chinese-qingming, holiday-chinese-winter-solstice)
Glenn Morris <rgm@gnu.org>
parents: 94018
diff changeset
499 (list 3 15 displayed-year)))))
70cc209bf336 (holiday-chinese-qingming, holiday-chinese-winter-solstice)
Glenn Morris <rgm@gnu.org>
parents: 94018
diff changeset
500 "Qingming Festival"))))
70cc209bf336 (holiday-chinese-qingming, holiday-chinese-winter-solstice)
Glenn Morris <rgm@gnu.org>
parents: 94018
diff changeset
501
70cc209bf336 (holiday-chinese-qingming, holiday-chinese-winter-solstice)
Glenn Morris <rgm@gnu.org>
parents: 94018
diff changeset
502 ;;;###holiday-autoload
70cc209bf336 (holiday-chinese-qingming, holiday-chinese-winter-solstice)
Glenn Morris <rgm@gnu.org>
parents: 94018
diff changeset
503 (defun holiday-chinese-winter-solstice ()
70cc209bf336 (holiday-chinese-qingming, holiday-chinese-winter-solstice)
Glenn Morris <rgm@gnu.org>
parents: 94018
diff changeset
504 "Date of Chinese winter solstice, if visible in calendar.
70cc209bf336 (holiday-chinese-qingming, holiday-chinese-winter-solstice)
Glenn Morris <rgm@gnu.org>
parents: 94018
diff changeset
505 Returns (((MONTH DAY YEAR) TEXT)), where the date is Gregorian."
70cc209bf336 (holiday-chinese-qingming, holiday-chinese-winter-solstice)
Glenn Morris <rgm@gnu.org>
parents: 94018
diff changeset
506 (when (memq displayed-month '(11 12 1)) ; is December visible?
70cc209bf336 (holiday-chinese-qingming, holiday-chinese-winter-solstice)
Glenn Morris <rgm@gnu.org>
parents: 94018
diff changeset
507 (list (list (calendar-gregorian-from-absolute
70cc209bf336 (holiday-chinese-qingming, holiday-chinese-winter-solstice)
Glenn Morris <rgm@gnu.org>
parents: 94018
diff changeset
508 (calendar-chinese-zodiac-sign-on-or-after
70cc209bf336 (holiday-chinese-qingming, holiday-chinese-winter-solstice)
Glenn Morris <rgm@gnu.org>
parents: 94018
diff changeset
509 (calendar-absolute-from-gregorian
70cc209bf336 (holiday-chinese-qingming, holiday-chinese-winter-solstice)
Glenn Morris <rgm@gnu.org>
parents: 94018
diff changeset
510 (list 12 15 (if (eq displayed-month 1)
70cc209bf336 (holiday-chinese-qingming, holiday-chinese-winter-solstice)
Glenn Morris <rgm@gnu.org>
parents: 94018
diff changeset
511 (1- displayed-year)
70cc209bf336 (holiday-chinese-qingming, holiday-chinese-winter-solstice)
Glenn Morris <rgm@gnu.org>
parents: 94018
diff changeset
512 displayed-year)))))
70cc209bf336 (holiday-chinese-qingming, holiday-chinese-winter-solstice)
Glenn Morris <rgm@gnu.org>
parents: 94018
diff changeset
513 "Winter Solstice Festival"))))
70cc209bf336 (holiday-chinese-qingming, holiday-chinese-winter-solstice)
Glenn Morris <rgm@gnu.org>
parents: 94018
diff changeset
514
70cc209bf336 (holiday-chinese-qingming, holiday-chinese-winter-solstice)
Glenn Morris <rgm@gnu.org>
parents: 94018
diff changeset
515 ;;;###holiday-autoload
70cc209bf336 (holiday-chinese-qingming, holiday-chinese-winter-solstice)
Glenn Morris <rgm@gnu.org>
parents: 94018
diff changeset
516 (defun holiday-chinese (month day string)
70cc209bf336 (holiday-chinese-qingming, holiday-chinese-winter-solstice)
Glenn Morris <rgm@gnu.org>
parents: 94018
diff changeset
517 "Holiday on Chinese MONTH, DAY called STRING.
70cc209bf336 (holiday-chinese-qingming, holiday-chinese-winter-solstice)
Glenn Morris <rgm@gnu.org>
parents: 94018
diff changeset
518 If MONTH, DAY (Chinese) is visible, returns the corresponding
70cc209bf336 (holiday-chinese-qingming, holiday-chinese-winter-solstice)
Glenn Morris <rgm@gnu.org>
parents: 94018
diff changeset
519 Gregorian date as the list (((month day year) STRING)).
70cc209bf336 (holiday-chinese-qingming, holiday-chinese-winter-solstice)
Glenn Morris <rgm@gnu.org>
parents: 94018
diff changeset
520 Returns nil if it is not visible in the current calendar window."
104864
f1938074431e (holiday-chinese): Make it slightly more efficient.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
521 (let ((date
f1938074431e (holiday-chinese): Make it slightly more efficient.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
522 (calendar-gregorian-from-absolute
f1938074431e (holiday-chinese): Make it slightly more efficient.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
523 ;; A basic optimization. Chinese year can only change if
f1938074431e (holiday-chinese): Make it slightly more efficient.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
524 ;; Jan or Feb are visible. FIXME can we do more?
f1938074431e (holiday-chinese): Make it slightly more efficient.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
525 (if (memq displayed-month '(12 1 2 3))
f1938074431e (holiday-chinese): Make it slightly more efficient.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
526 ;; This is calendar-nongregorian-visible-p adapted for
f1938074431e (holiday-chinese): Make it slightly more efficient.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
527 ;; the form of chinese dates: (cycle year month day) as
f1938074431e (holiday-chinese): Make it slightly more efficient.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
528 ;; opposed to (month day year).
f1938074431e (holiday-chinese): Make it slightly more efficient.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
529 (let* ((m1 displayed-month)
f1938074431e (holiday-chinese): Make it slightly more efficient.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
530 (y1 displayed-year)
f1938074431e (holiday-chinese): Make it slightly more efficient.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
531 (m2 displayed-month)
f1938074431e (holiday-chinese): Make it slightly more efficient.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
532 (y2 displayed-year)
f1938074431e (holiday-chinese): Make it slightly more efficient.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
533 ;; Absolute date of first/last dates in calendar window.
f1938074431e (holiday-chinese): Make it slightly more efficient.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
534 (start-date (progn
f1938074431e (holiday-chinese): Make it slightly more efficient.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
535 (calendar-increment-month m1 y1 -1)
f1938074431e (holiday-chinese): Make it slightly more efficient.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
536 (calendar-absolute-from-gregorian
f1938074431e (holiday-chinese): Make it slightly more efficient.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
537 (list m1 1 y1))))
f1938074431e (holiday-chinese): Make it slightly more efficient.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
538 (end-date (progn
f1938074431e (holiday-chinese): Make it slightly more efficient.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
539 (calendar-increment-month m2 y2 1)
f1938074431e (holiday-chinese): Make it slightly more efficient.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
540 (calendar-absolute-from-gregorian
f1938074431e (holiday-chinese): Make it slightly more efficient.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
541 (list m2 (calendar-last-day-of-month m2 y2)
f1938074431e (holiday-chinese): Make it slightly more efficient.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
542 y2))))
f1938074431e (holiday-chinese): Make it slightly more efficient.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
543 ;; Local date of first/last date in calendar window.
f1938074431e (holiday-chinese): Make it slightly more efficient.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
544 (local-start (calendar-chinese-from-absolute start-date))
f1938074431e (holiday-chinese): Make it slightly more efficient.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
545 (local-end (calendar-chinese-from-absolute end-date))
f1938074431e (holiday-chinese): Make it slightly more efficient.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
546 ;; When Chinese New Year is visible on the far
f1938074431e (holiday-chinese): Make it slightly more efficient.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
547 ;; right of the calendar, what is the earliest
f1938074431e (holiday-chinese): Make it slightly more efficient.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
548 ;; Chinese month in the previous year that might
f1938074431e (holiday-chinese): Make it slightly more efficient.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
549 ;; still visible? This test doesn't have to be precise.
f1938074431e (holiday-chinese): Make it slightly more efficient.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
550 (local (if (< month 10) local-end local-start))
f1938074431e (holiday-chinese): Make it slightly more efficient.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
551 (cycle (car local))
f1938074431e (holiday-chinese): Make it slightly more efficient.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
552 (year (cadr local)))
f1938074431e (holiday-chinese): Make it slightly more efficient.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
553 (calendar-chinese-to-absolute (list cycle year month day)))
f1938074431e (holiday-chinese): Make it slightly more efficient.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
554 ;; Simple form for when new years are not visible.
f1938074431e (holiday-chinese): Make it slightly more efficient.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
555 (+ (cadr (assoc month (calendar-chinese-year displayed-year)))
f1938074431e (holiday-chinese): Make it slightly more efficient.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
556 (1- day))))))
94282
70cc209bf336 (holiday-chinese-qingming, holiday-chinese-winter-solstice)
Glenn Morris <rgm@gnu.org>
parents: 94018
diff changeset
557 (if (calendar-date-is-visible-p date)
70cc209bf336 (holiday-chinese-qingming, holiday-chinese-winter-solstice)
Glenn Morris <rgm@gnu.org>
parents: 94018
diff changeset
558 (list (list date string)))))
70cc209bf336 (holiday-chinese-qingming, holiday-chinese-winter-solstice)
Glenn Morris <rgm@gnu.org>
parents: 94018
diff changeset
559
92827
02fc7543d146 (generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents: 92660
diff changeset
560 ;;;###cal-autoload
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
561 (defun calendar-chinese-date-string (&optional date)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
562 "String of Chinese date of Gregorian DATE.
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
563 Defaults to today's date if DATE is not given."
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
564 (let* ((a-date (calendar-absolute-from-gregorian
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
565 (or date (calendar-current-date))))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
566 (c-date (calendar-chinese-from-absolute a-date))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
567 (cycle (car c-date))
92900
c6b7fe651716 Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents: 92827
diff changeset
568 (year (cadr c-date))
c6b7fe651716 Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents: 92827
diff changeset
569 (month (nth 2 c-date))
c6b7fe651716 Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents: 92827
diff changeset
570 (day (nth 3 c-date))
93739
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
571 (this-month (calendar-chinese-to-absolute
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
572 (list cycle year month 1)))
93739
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
573 (next-month (calendar-chinese-to-absolute
13283
f8658d1ca0f2 Various fixes and simplifications.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents: 13281
diff changeset
574 (list (if (= year 60) (1+ cycle) cycle)
f8658d1ca0f2 Various fixes and simplifications.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents: 13281
diff changeset
575 (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
576 ;; 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
577 ;; 12 instead of 0.
130c0da046a4 (calendar-chinese-from-absolute, calendar-chinese-date-string): Expand
Glenn Morris <rgm@gnu.org>
parents: 92967
diff changeset
578 (1+ (mod (floor month) 12))
13283
f8658d1ca0f2 Various fixes and simplifications.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents: 13281
diff changeset
579 1)))
13281
510f946d1e22 Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents: 13053
diff changeset
580 (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
581 (format "Cycle %s, year %s (%s), %smonth %s%s, day %s (%s)"
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
582 cycle
13675
280cee006df8 (calendar-chinese-sexagesimal-name): Renamed from
Paul Eggert <eggert@twinsun.com>
parents: 13574
diff changeset
583 year (calendar-chinese-sexagesimal-name year)
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
584 (if (not (integerp month))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
585 "second "
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
586 (if (< 30 (- next-month this-month))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
587 "first "
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
588 ""))
13281
510f946d1e22 Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents: 13053
diff changeset
589 (floor month)
13306
77d8e407592e Fix the way the sexagisimal names are calculated.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents: 13284
diff changeset
590 (if (integerp month)
13675
280cee006df8 (calendar-chinese-sexagesimal-name): Renamed from
Paul Eggert <eggert@twinsun.com>
parents: 13574
diff changeset
591 (format " (%s)" (calendar-chinese-sexagesimal-name
20215
13b173216a3d (calendar-chinese-date-string): Fix month name.
Karl Heuer <kwzh@gnu.org>
parents: 19903
diff changeset
592 (+ (* 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
593 "")
13675
280cee006df8 (calendar-chinese-sexagesimal-name): Renamed from
Paul Eggert <eggert@twinsun.com>
parents: 13574
diff changeset
594 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
595
92827
02fc7543d146 (generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents: 92660
diff changeset
596 ;;;###cal-autoload
93739
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
597 (defun calendar-chinese-print-date ()
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
598 "Show the Chinese date equivalents of date."
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
599 (interactive)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
600 (message "Computing Chinese date...")
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
601 (message "Chinese date: %s"
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
602 (calendar-chinese-date-string (calendar-cursor-to-date t))))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
603
93739
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
604 (define-obsolete-function-alias 'calendar-print-chinese-date
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
605 'calendar-chinese-print-date "23.1")
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
606
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
607 (defun calendar-chinese-months-to-alist (l)
92900
c6b7fe651716 Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents: 92827
diff changeset
608 "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
609 (and l (car l)
c6b7fe651716 Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents: 92827
diff changeset
610 (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
611 (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
612 (append
c6b7fe651716 Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents: 92827
diff changeset
613 (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
614 (cons (format "%s (second)" (car l)) (cadr l)))
93739
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
615 (calendar-chinese-months-to-alist (cddr l)))
92900
c6b7fe651716 Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents: 92827
diff changeset
616 (append
93844
bf9ef749c23e Replace int-to-string with number-to-string.
Glenn Morris <rgm@gnu.org>
parents: 93809
diff changeset
617 (list (cons (number-to-string (car l)) (car l)))
93739
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
618 (calendar-chinese-months-to-alist (cdr l))))
93844
bf9ef749c23e Replace int-to-string with number-to-string.
Glenn Morris <rgm@gnu.org>
parents: 93809
diff changeset
619 (list (cons (number-to-string (car l)) (car l))))))
92900
c6b7fe651716 Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents: 92827
diff changeset
620
93739
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
621 (defun calendar-chinese-months (c y)
92900
c6b7fe651716 Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents: 92827
diff changeset
622 "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
623 (memq 1 (append
c6b7fe651716 Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents: 92827
diff changeset
624 (mapcar (lambda (x)
c6b7fe651716 Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents: 92827
diff changeset
625 (car x))
93809
3ff2b47de8f2 Update for calendar.el name changes.
Glenn Morris <rgm@gnu.org>
parents: 93779
diff changeset
626 (calendar-chinese-year (calendar-extract-year
93739
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
627 (calendar-gregorian-from-absolute
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
628 (calendar-chinese-to-absolute
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
629 (list c y 1 1))))))
92900
c6b7fe651716 Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents: 92827
diff changeset
630 (mapcar (lambda (x)
c6b7fe651716 Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents: 92827
diff changeset
631 (if (> (car x) 11) (car x)))
93809
3ff2b47de8f2 Update for calendar.el name changes.
Glenn Morris <rgm@gnu.org>
parents: 93779
diff changeset
632 (calendar-chinese-year (calendar-extract-year
93739
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
633 (calendar-gregorian-from-absolute
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
634 (calendar-chinese-to-absolute
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
635 (list (if (= y 60) (1+ c) c)
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
636 (if (= y 60) 1 y)
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
637 1 1)))))))))
92900
c6b7fe651716 Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents: 92827
diff changeset
638
92827
02fc7543d146 (generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents: 92660
diff changeset
639 ;;;###cal-autoload
93739
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
640 (defun calendar-chinese-goto-date (date &optional noecho)
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
641 "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
642 Echo Chinese date unless NOECHO is non-nil."
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
643 (interactive
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
644 (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
645 (calendar-absolute-from-gregorian (calendar-current-date))))
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
646 (cycle (calendar-read
13281
510f946d1e22 Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents: 13053
diff changeset
647 "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
648 (lambda (x) (> x 44))
93844
bf9ef749c23e Replace int-to-string with number-to-string.
Glenn Morris <rgm@gnu.org>
parents: 93809
diff changeset
649 (number-to-string (car c))))
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
650 (year (calendar-read
13281
510f946d1e22 Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents: 13053
diff changeset
651 "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
652 (lambda (x) (and (<= 1 x) (<= x 60)))
93844
bf9ef749c23e Replace int-to-string with number-to-string.
Glenn Morris <rgm@gnu.org>
parents: 93809
diff changeset
653 (number-to-string (cadr c))))
93739
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
654 (month-list (calendar-chinese-months-to-alist
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
655 (calendar-chinese-months cycle year)))
13281
510f946d1e22 Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents: 13053
diff changeset
656 (month (cdr (assoc
510f946d1e22 Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents: 13053
diff changeset
657 (completing-read "Chinese calendar month: "
510f946d1e22 Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents: 13053
diff changeset
658 month-list nil t)
510f946d1e22 Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents: 13053
diff changeset
659 month-list)))
510f946d1e22 Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents: 13053
diff changeset
660 (last (if (= month
92900
c6b7fe651716 Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents: 92827
diff changeset
661 (nth 2
c6b7fe651716 Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents: 92827
diff changeset
662 (calendar-chinese-from-absolute
c6b7fe651716 Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents: 92827
diff changeset
663 (+ 29
93739
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
664 (calendar-chinese-to-absolute
92900
c6b7fe651716 Re-order so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents: 92827
diff changeset
665 (list cycle year month 1))))))
13281
510f946d1e22 Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents: 13053
diff changeset
666 30
510f946d1e22 Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents: 13053
diff changeset
667 29))
510f946d1e22 Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents: 13053
diff changeset
668 (day (calendar-read
510f946d1e22 Completely rewritten!
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents: 13053
diff changeset
669 (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
670 (lambda (x) (and (<= 1 x) (<= x last))))))
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
671 (list (list cycle year month day))))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
672 (calendar-goto-date (calendar-gregorian-from-absolute
93739
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
673 (calendar-chinese-to-absolute date)))
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
674 (or noecho (calendar-chinese-print-date)))
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
675
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
676 (define-obsolete-function-alias 'calendar-goto-chinese-date
14357375e115 (calendar-chinese): Rename custom group from chinese-calendar. Update users.
Glenn Morris <rgm@gnu.org>
parents: 93637
diff changeset
677 'calendar-chinese-goto-date "23.1")
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
678
92614
52850e6ad92b Comment.
Glenn Morris <rgm@gnu.org>
parents: 92579
diff changeset
679 (defvar date)
52850e6ad92b Comment.
Glenn Morris <rgm@gnu.org>
parents: 92579
diff changeset
680
93779
089c13c26a10 Comment.
Glenn Morris <rgm@gnu.org>
parents: 93739
diff changeset
681 ;; To be called from diary-list-sexp-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
682 ;;;###diary-autoload
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
683 (defun diary-chinese-date ()
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
684 "Chinese calendar equivalent of date diary entry."
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
685 (format "Chinese date: %s" (calendar-chinese-date-string date)))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
686
14685
496342156d13 Renamed from cal-chinese.el to avoid 14-character limitation.
Karl Heuer <kwzh@gnu.org>
parents: 14169
diff changeset
687 (provide 'cal-china)
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
688
14685
496342156d13 Renamed from cal-chinese.el to avoid 14-character limitation.
Karl Heuer <kwzh@gnu.org>
parents: 14169
diff changeset
689 ;;; cal-china.el ends here