Commit | Line | Data |
---|---|---|
1a06eabd | 1 | ;;; holidays.el --- holiday functions for the calendar package |
fc68affa | 2 | |
73b0cd50 | 3 | ;; Copyright (C) 1989-1990, 1992-1994, 1997, 2001-2011 |
e9bffc61 | 4 | ;; Free Software Foundation, Inc. |
3a801d0c | 5 | |
fc68affa | 6 | ;; Author: Edward M. Reingold <reingold@cs.uiuc.edu> |
aff88519 | 7 | ;; Maintainer: Glenn Morris <rgm@gnu.org> |
7e1dae73 | 8 | ;; Keywords: holidays, calendar |
bd78fa1d | 9 | ;; Package: calendar |
fc68affa | 10 | |
1802278a JB |
11 | ;; This file is part of GNU Emacs. |
12 | ||
2ed66575 | 13 | ;; GNU Emacs is free software: you can redistribute it and/or modify |
59243403 | 14 | ;; it under the terms of the GNU General Public License as published by |
2ed66575 GM |
15 | ;; the Free Software Foundation, either version 3 of the License, or |
16 | ;; (at your option) any later version. | |
8ec105a0 | 17 | |
1802278a | 18 | ;; GNU Emacs is distributed in the hope that it will be useful, |
59243403 RS |
19 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
20 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
21 | ;; GNU General Public License for more details. | |
22 | ||
23 | ;; You should have received a copy of the GNU General Public License | |
2ed66575 | 24 | ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
1802278a | 25 | |
fc68affa ER |
26 | ;;; Commentary: |
27 | ||
d600b865 | 28 | ;; See calendar.el. |
1802278a | 29 | |
fc68affa ER |
30 | ;;; Code: |
31 | ||
1802278a | 32 | (require 'calendar) |
e8a11b22 | 33 | (load "hol-loaddefs" nil t) |
7e1dae73 | 34 | |
d463476b GM |
35 | (defgroup holidays nil |
36 | "Holidays support in calendar." | |
37 | :group 'calendar | |
38 | :prefix "holidays-" | |
39 | :group 'local) | |
40 | ||
41 | ;; The various holiday variables are autoloaded because people | |
42 | ;; are used to using them to set calendar-holidays without having to | |
43 | ;; explicitly load this file. | |
44 | ||
919dd7aa GM |
45 | ;;;###autoload |
46 | (define-obsolete-variable-alias 'general-holidays | |
47 | 'holiday-general-holidays "23.1") | |
d463476b GM |
48 | ;;;###autoload |
49 | (defcustom holiday-general-holidays | |
1e8780b1 | 50 | (mapcar 'purecopy |
d463476b GM |
51 | '((holiday-fixed 1 1 "New Year's Day") |
52 | (holiday-float 1 1 3 "Martin Luther King Day") | |
53 | (holiday-fixed 2 2 "Groundhog Day") | |
54 | (holiday-fixed 2 14 "Valentine's Day") | |
55 | (holiday-float 2 1 3 "President's Day") | |
56 | (holiday-fixed 3 17 "St. Patrick's Day") | |
57 | (holiday-fixed 4 1 "April Fools' Day") | |
58 | (holiday-float 5 0 2 "Mother's Day") | |
59 | (holiday-float 5 1 -1 "Memorial Day") | |
60 | (holiday-fixed 6 14 "Flag Day") | |
61 | (holiday-float 6 0 3 "Father's Day") | |
62 | (holiday-fixed 7 4 "Independence Day") | |
63 | (holiday-float 9 1 1 "Labor Day") | |
64 | (holiday-float 10 1 2 "Columbus Day") | |
65 | (holiday-fixed 10 31 "Halloween") | |
66 | (holiday-fixed 11 11 "Veteran's Day") | |
1e8780b1 | 67 | (holiday-float 11 4 4 "Thanksgiving"))) |
d463476b GM |
68 | "General holidays. Default value is for the United States. |
69 | See the documentation for `calendar-holidays' for details." | |
70 | :type 'sexp | |
71 | :group 'holidays) | |
72 | ;;;###autoload | |
73 | (put 'holiday-general-holidays 'risky-local-variable t) | |
d463476b | 74 | |
919dd7aa GM |
75 | ;;;###autoload |
76 | (define-obsolete-variable-alias 'oriental-holidays | |
77 | 'holiday-oriental-holidays "23.1") | |
d463476b GM |
78 | ;;;###autoload |
79 | (defcustom holiday-oriental-holidays | |
1e8780b1 | 80 | (mapcar 'purecopy |
43c783b8 GM |
81 | '((holiday-chinese-new-year) |
82 | (if calendar-chinese-all-holidays-flag | |
83 | (append | |
84 | (holiday-chinese 1 15 "Lantern Festival") | |
85 | (holiday-chinese-qingming) | |
86 | (holiday-chinese 5 5 "Dragon Boat Festival") | |
87 | (holiday-chinese 7 7 "Double Seventh Festival") | |
88 | (holiday-chinese 8 15 "Mid-Autumn Festival") | |
89 | (holiday-chinese 9 9 "Double Ninth Festival") | |
90 | (holiday-chinese-winter-solstice) | |
1e8780b1 | 91 | )))) |
d463476b GM |
92 | "Oriental holidays. |
93 | See the documentation for `calendar-holidays' for details." | |
43c783b8 | 94 | :version "23.1" ; added more holidays |
d463476b GM |
95 | :type 'sexp |
96 | :group 'holidays) | |
97 | ;;;###autoload | |
98 | (put 'holiday-oriental-holidays 'risky-local-variable t) | |
d463476b | 99 | |
919dd7aa GM |
100 | ;;;###autoload |
101 | (define-obsolete-variable-alias 'local-holidays 'holiday-local-holidays "23.1") | |
d463476b GM |
102 | ;;;###autoload |
103 | (defcustom holiday-local-holidays nil | |
104 | "Local holidays. | |
105 | See the documentation for `calendar-holidays' for details." | |
106 | :type 'sexp | |
107 | :group 'holidays) | |
108 | ;;;###autoload | |
109 | (put 'holiday-local-holidays 'risky-local-variable t) | |
d463476b | 110 | |
919dd7aa GM |
111 | ;;;###autoload |
112 | (define-obsolete-variable-alias 'other-holidays 'holiday-other-holidays "23.1") | |
d463476b GM |
113 | ;;;###autoload |
114 | (defcustom holiday-other-holidays nil | |
115 | "User defined holidays. | |
116 | See the documentation for `calendar-holidays' for details." | |
117 | :type 'sexp | |
118 | :group 'holidays) | |
119 | ;;;###autoload | |
120 | (put 'holiday-other-holidays 'risky-local-variable t) | |
d463476b GM |
121 | |
122 | ;;;###autoload | |
123 | (defvar hebrew-holidays-1 | |
1e8780b1 | 124 | (mapcar 'purecopy |
d463476b GM |
125 | '((holiday-hebrew-rosh-hashanah) |
126 | (if calendar-hebrew-all-holidays-flag | |
127 | (holiday-julian | |
128 | 11 | |
129 | (let ((m displayed-month) | |
130 | (y displayed-year) | |
131 | year) | |
132 | (calendar-increment-month m y -1) | |
133 | (setq year (calendar-extract-year | |
134 | (calendar-julian-from-absolute | |
135 | (calendar-absolute-from-gregorian (list m 1 y))))) | |
136 | (if (zerop (% (1+ year) 4)) | |
137 | 22 | |
1e8780b1 | 138 | 21)) "\"Tal Umatar\" (evening)")))) |
d463476b GM |
139 | "Component of the old default value of `holiday-hebrew-holidays'.") |
140 | ;;;###autoload | |
141 | (put 'hebrew-holidays-1 'risky-local-variable t) | |
142 | (make-obsolete-variable 'hebrew-holidays-1 'hebrew-holidays "23.1") | |
143 | ||
144 | ;;;###autoload | |
145 | (defvar hebrew-holidays-2 | |
1e8780b1 | 146 | (mapcar 'purecopy |
d463476b GM |
147 | '((holiday-hebrew-hanukkah) ; respects calendar-hebrew-all-holidays-flag |
148 | (if calendar-hebrew-all-holidays-flag | |
149 | (holiday-hebrew | |
150 | 10 | |
151 | (let ((h-year (calendar-extract-year | |
152 | (calendar-hebrew-from-absolute | |
153 | (calendar-absolute-from-gregorian | |
154 | (list displayed-month 28 displayed-year)))))) | |
155 | (if (= 6 (% (calendar-hebrew-to-absolute (list 10 10 h-year)) | |
156 | 7)) | |
157 | 11 10)) | |
158 | "Tzom Teveth")) | |
159 | (if calendar-hebrew-all-holidays-flag | |
1e8780b1 | 160 | (holiday-hebrew 11 15 "Tu B'Shevat")))) |
d463476b GM |
161 | "Component of the old default value of `holiday-hebrew-holidays'.") |
162 | ;;;###autoload | |
163 | (put 'hebrew-holidays-2 'risky-local-variable t) | |
164 | (make-obsolete-variable 'hebrew-holidays-2 'hebrew-holidays "23.1") | |
165 | ||
166 | ;;;###autoload | |
167 | (defvar hebrew-holidays-3 | |
1e8780b1 | 168 | (mapcar 'purecopy |
d463476b GM |
169 | '((if calendar-hebrew-all-holidays-flag |
170 | (holiday-hebrew | |
171 | 11 | |
172 | (let* ((m displayed-month) | |
173 | (y displayed-year) | |
174 | (h-year (progn | |
175 | (calendar-increment-month m y 1) | |
176 | (calendar-extract-year | |
177 | (calendar-hebrew-from-absolute | |
178 | (calendar-absolute-from-gregorian | |
179 | (list m (calendar-last-day-of-month m y) y)))))) | |
180 | (s-s | |
181 | (calendar-hebrew-from-absolute | |
182 | (if (= 6 | |
183 | (% (calendar-hebrew-to-absolute | |
184 | (list 7 1 h-year)) | |
185 | 7)) | |
186 | (calendar-dayname-on-or-before | |
187 | 6 (calendar-hebrew-to-absolute | |
188 | (list 11 17 h-year))) | |
189 | (calendar-dayname-on-or-before | |
190 | 6 (calendar-hebrew-to-absolute | |
191 | (list 11 16 h-year)))))) | |
192 | (day (calendar-extract-day s-s))) | |
193 | day) | |
1e8780b1 | 194 | "Shabbat Shirah")))) |
d463476b GM |
195 | "Component of the old default value of `holiday-hebrew-holidays'.") |
196 | ;;;###autoload | |
197 | (put 'hebrew-holidays-3 'risky-local-variable t) | |
198 | (make-obsolete-variable 'hebrew-holidays-3 'hebrew-holidays "23.1") | |
199 | ||
200 | ;;;###autoload | |
201 | (defvar hebrew-holidays-4 | |
1e8780b1 | 202 | (mapcar 'purecopy |
d463476b GM |
203 | '((holiday-hebrew-passover) |
204 | (and calendar-hebrew-all-holidays-flag | |
205 | (let* ((m displayed-month) | |
206 | (y displayed-year) | |
207 | (year (progn | |
208 | (calendar-increment-month m y -1) | |
209 | (calendar-extract-year | |
210 | (calendar-julian-from-absolute | |
211 | (calendar-absolute-from-gregorian (list m 1 y))))))) | |
212 | (= 21 (% year 28))) | |
213 | (holiday-julian 3 26 "Kiddush HaHamah")) | |
214 | (if calendar-hebrew-all-holidays-flag | |
1e8780b1 | 215 | (holiday-hebrew-tisha-b-av)))) |
d463476b GM |
216 | "Component of the old default value of `holiday-hebrew-holidays'.") |
217 | ;;;###autoload | |
218 | (put 'hebrew-holidays-4 'risky-local-variable t) | |
219 | (make-obsolete-variable 'hebrew-holidays-4 'hebrew-holidays "23.1") | |
220 | ||
919dd7aa GM |
221 | ;;;###autoload |
222 | (define-obsolete-variable-alias 'hebrew-holidays | |
223 | 'holiday-hebrew-holidays "23.1") | |
d463476b GM |
224 | ;;;###autoload |
225 | (defcustom holiday-hebrew-holidays | |
1e8780b1 | 226 | (mapcar 'purecopy |
d463476b GM |
227 | '((holiday-hebrew-passover) |
228 | (holiday-hebrew-rosh-hashanah) | |
229 | (holiday-hebrew-hanukkah) | |
230 | (if calendar-hebrew-all-holidays-flag | |
231 | (append | |
232 | (holiday-hebrew-tisha-b-av) | |
1e8780b1 | 233 | (holiday-hebrew-misc))))) |
d463476b GM |
234 | "Jewish holidays. |
235 | See the documentation for `calendar-holidays' for details." | |
236 | :type 'sexp | |
237 | :version "23.1" ; removed dependency on hebrew-holidays-N | |
238 | :group 'holidays) | |
239 | ;;;###autoload | |
240 | (put 'holiday-hebrew-holidays 'risky-local-variable t) | |
d463476b | 241 | |
919dd7aa GM |
242 | ;;;###autoload |
243 | (define-obsolete-variable-alias 'christian-holidays | |
244 | 'holiday-christian-holidays "23.1") | |
d463476b GM |
245 | ;;;###autoload |
246 | (defcustom holiday-christian-holidays | |
1e8780b1 | 247 | (mapcar 'purecopy |
d463476b GM |
248 | '((holiday-easter-etc) ; respects calendar-christian-all-holidays-flag |
249 | (holiday-fixed 12 25 "Christmas") | |
250 | (if calendar-christian-all-holidays-flag | |
251 | (append | |
252 | (holiday-fixed 1 6 "Epiphany") | |
253 | (holiday-julian 12 25 "Eastern Orthodox Christmas") | |
254 | (holiday-greek-orthodox-easter) | |
255 | (holiday-fixed 8 15 "Assumption") | |
1e8780b1 | 256 | (holiday-advent 0 "Advent"))))) |
d463476b GM |
257 | "Christian holidays. |
258 | See the documentation for `calendar-holidays' for details." | |
259 | :type 'sexp | |
260 | :group 'holidays) | |
261 | ;;;###autoload | |
262 | (put 'holiday-christian-holidays 'risky-local-variable t) | |
d463476b | 263 | |
919dd7aa GM |
264 | ;;;###autoload |
265 | (define-obsolete-variable-alias 'islamic-holidays | |
266 | 'holiday-islamic-holidays "23.1") | |
d463476b GM |
267 | ;;;###autoload |
268 | (defcustom holiday-islamic-holidays | |
1e8780b1 | 269 | (mapcar 'purecopy |
d463476b GM |
270 | '((holiday-islamic-new-year) |
271 | (holiday-islamic 9 1 "Ramadan Begins") | |
272 | (if calendar-islamic-all-holidays-flag | |
273 | (append | |
274 | (holiday-islamic 1 10 "Ashura") | |
275 | (holiday-islamic 3 12 "Mulad-al-Nabi") | |
276 | (holiday-islamic 7 26 "Shab-e-Mi'raj") | |
277 | (holiday-islamic 8 15 "Shab-e-Bara't") | |
278 | (holiday-islamic 9 27 "Shab-e Qadr") | |
279 | (holiday-islamic 10 1 "Id-al-Fitr") | |
1e8780b1 | 280 | (holiday-islamic 12 10 "Id-al-Adha"))))) |
d463476b GM |
281 | "Islamic holidays. |
282 | See the documentation for `calendar-holidays' for details." | |
283 | :type 'sexp | |
284 | :group 'holidays) | |
285 | ;;;###autoload | |
286 | (put 'holiday-islamic-holidays 'risky-local-variable t) | |
d463476b | 287 | |
919dd7aa GM |
288 | ;;;###autoload |
289 | (define-obsolete-variable-alias 'bahai-holidays 'holiday-bahai-holidays "23.1") | |
d463476b GM |
290 | ;;;###autoload |
291 | (defcustom holiday-bahai-holidays | |
1e8780b1 | 292 | (mapcar 'purecopy |
d463476b GM |
293 | '((holiday-bahai-new-year) |
294 | (holiday-bahai-ridvan) ; respects calendar-bahai-all-holidays-flag | |
295 | (holiday-fixed 5 23 "Declaration of the Bab") | |
296 | (holiday-fixed 5 29 "Ascension of Baha'u'llah") | |
297 | (holiday-fixed 7 9 "Martyrdom of the Bab") | |
298 | (holiday-fixed 10 20 "Birth of the Bab") | |
299 | (holiday-fixed 11 12 "Birth of Baha'u'llah") | |
300 | (if calendar-bahai-all-holidays-flag | |
301 | (append | |
302 | (holiday-fixed 11 26 "Day of the Covenant") | |
1e8780b1 | 303 | (holiday-fixed 11 28 "Ascension of `Abdu'l-Baha"))))) |
d463476b GM |
304 | "Baha'i holidays. |
305 | See the documentation for `calendar-holidays' for details." | |
306 | :type 'sexp | |
307 | :group 'holidays) | |
308 | ;;;###autoload | |
309 | (put 'holiday-bahai-holidays 'risky-local-variable t) | |
d463476b | 310 | |
919dd7aa GM |
311 | ;;;###autoload |
312 | (define-obsolete-variable-alias 'solar-holidays 'holiday-solar-holidays "23.1") | |
d463476b GM |
313 | ;;;###autoload |
314 | (defcustom holiday-solar-holidays | |
1e8780b1 | 315 | (mapcar 'purecopy |
d463476b GM |
316 | '((solar-equinoxes-solstices) |
317 | (holiday-sexp calendar-daylight-savings-starts | |
318 | (format "Daylight Saving Time Begins %s" | |
319 | (solar-time-string | |
320 | (/ calendar-daylight-savings-starts-time (float 60)) | |
321 | calendar-standard-time-zone-name))) | |
322 | (holiday-sexp calendar-daylight-savings-ends | |
323 | (format "Daylight Saving Time Ends %s" | |
324 | (solar-time-string | |
325 | (/ calendar-daylight-savings-ends-time (float 60)) | |
1e8780b1 | 326 | calendar-daylight-time-zone-name))))) |
d463476b GM |
327 | "Sun-related holidays. |
328 | See the documentation for `calendar-holidays' for details." | |
329 | :type 'sexp | |
330 | :group 'holidays) | |
331 | ;;;###autoload | |
332 | (put 'holiday-solar-holidays 'risky-local-variable t) | |
d463476b | 333 | |
64b7c58a GM |
334 | ;; This one should not be autoloaded, else .emacs changes of |
335 | ;; holiday-general-holidays etc have no effect. | |
336 | ;; FIXME should have some :set-after. | |
d463476b GM |
337 | (defcustom calendar-holidays |
338 | (append holiday-general-holidays holiday-local-holidays | |
339 | holiday-other-holidays holiday-christian-holidays | |
340 | holiday-hebrew-holidays holiday-islamic-holidays | |
341 | holiday-bahai-holidays holiday-oriental-holidays | |
342 | holiday-solar-holidays) | |
343 | "List of notable days for the command \\[holidays]. | |
344 | ||
345 | Additional holidays are easy to add to the list, just put them in the | |
346 | list `holiday-other-holidays' in your .emacs file. Similarly, by setting | |
347 | any of `holiday-general-holidays', `holiday-local-holidays', | |
348 | `holiday-christian-holidays', `holiday-hebrew-holidays', | |
349 | `holiday-islamic-holidays', `holiday-bahai-holidays', | |
350 | `holiday-oriental-holidays', or `holiday-solar-holidays' to nil in your | |
351 | .emacs file, you can eliminate unwanted categories of holidays. | |
352 | ||
353 | The aforementioned variables control the holiday choices offered | |
354 | by the function `holiday-list' when it is called interactively. | |
355 | ||
356 | They also initialize the default value of `calendar-holidays', | |
357 | which is the default list of holidays used by the function | |
358 | `holiday-list' in the non-interactive case. Note that these | |
359 | variables have no effect on `calendar-holidays' after it has been | |
360 | set (e.g. after the calendar is loaded). In that case, customize | |
361 | `calendar-holidays' directly. | |
362 | ||
363 | The intention is that (in the US) `holiday-local-holidays' be set in | |
364 | site-init.el and `holiday-other-holidays' be set by the user. | |
365 | ||
366 | Entries on the list are expressions that return (possibly empty) lists of | |
367 | items of the form ((month day year) string) of a holiday in the | |
368 | three-month period centered around `displayed-month' of `displayed-year'. | |
369 | Several basic functions are provided for this purpose: | |
370 | ||
371 | (holiday-fixed MONTH DAY STRING) is a fixed date on the Gregorian calendar | |
19b1a5bc GM |
372 | (holiday-float MONTH DAYNAME K STRING &optional DAY) is the Kth DAYNAME |
373 | (0 for Sunday, etc.) after/before Gregorian | |
374 | MONTH DAY. K<0 means count back from the end | |
375 | of the month. Optional DAY defaults to 1 if | |
376 | K>0, and MONTH's last day otherwise. | |
d463476b GM |
377 | (holiday-hebrew MONTH DAY STRING) a fixed date on the Hebrew calendar |
378 | (holiday-islamic MONTH DAY STRING) a fixed date on the Islamic calendar | |
379 | (holiday-bahai MONTH DAY STRING) a fixed date on the Baha'i calendar | |
380 | (holiday-julian MONTH DAY STRING) a fixed date on the Julian calendar | |
381 | (holiday-sexp SEXP STRING) SEXP is a Gregorian-date-valued expression | |
382 | in the variable `year'; if it evaluates to | |
383 | a visible date, that's the holiday; if it | |
384 | evaluates to nil, there's no holiday. STRING | |
385 | is an expression in the variable `date'. | |
386 | ||
387 | For example, to add Bastille Day, celebrated in France on July 14, add | |
388 | ||
389 | (holiday-fixed 7 14 \"Bastille Day\") | |
390 | ||
391 | to the list. To add Hurricane Supplication Day, celebrated in the Virgin | |
392 | Islands on the fourth Monday in August, add | |
393 | ||
394 | (holiday-float 8 1 4 \"Hurricane Supplication Day\") | |
395 | ||
396 | to the list (the last Monday would be specified with `-1' instead of `4'). | |
397 | To add the last day of Hanukkah to the list, use | |
398 | ||
399 | (holiday-hebrew 10 2 \"Last day of Hanukkah\") | |
400 | ||
401 | since the Hebrew months are numbered with 1 starting from Nisan. | |
402 | To add the Islamic feast celebrating Mohammed's birthday, use | |
403 | ||
404 | (holiday-islamic 3 12 \"Mohammed's Birthday\") | |
405 | ||
406 | since the Islamic months are numbered from 1 starting with Muharram. | |
407 | To add an entry for the Baha'i festival of Ridvan, use | |
408 | ||
409 | (holiday-bahai 2 13 \"Festival of Ridvan\") | |
410 | ||
411 | since the Baha'i months are numbered from 1 starting with Baha. | |
412 | To add Thomas Jefferson's birthday, April 2, 1743 (Julian), use | |
413 | ||
414 | (holiday-julian 4 2 \"Jefferson's Birthday\") | |
415 | ||
416 | To include a holiday conditionally, use the sexp form or a conditional. For | |
417 | example, to include American presidential elections, which occur on the first | |
418 | Tuesday after the first Monday in November of years divisible by 4, add | |
419 | ||
420 | (holiday-sexp | |
421 | '(if (zerop (% year 4)) | |
422 | (calendar-gregorian-from-absolute | |
423 | (1+ (calendar-dayname-on-or-before | |
424 | 1 (+ 6 (calendar-absolute-from-gregorian | |
425 | (list 11 1 year))))))) | |
426 | \"US Presidential Election\") | |
427 | ||
428 | or | |
429 | ||
430 | (if (zerop (% displayed-year 4)) | |
431 | (holiday-fixed 11 | |
432 | (calendar-extract-day | |
433 | (calendar-gregorian-from-absolute | |
434 | (1+ (calendar-dayname-on-or-before | |
435 | 1 (+ 6 (calendar-absolute-from-gregorian | |
436 | (list 11 1 displayed-year))))))) | |
437 | \"US Presidential Election\")) | |
438 | ||
439 | to the list. To include the phases of the moon, add | |
440 | ||
441 | (lunar-phases) | |
442 | ||
443 | to the holiday list, where `lunar-phases' is an Emacs-Lisp function that | |
444 | you've written to return a (possibly empty) list of the relevant VISIBLE dates | |
445 | with descriptive strings such as | |
446 | ||
447 | (((2 6 1989) \"New Moon\") ((2 12 1989) \"First Quarter Moon\") ... )." | |
448 | :type 'sexp | |
449 | :group 'holidays) | |
450 | ;;;###autoload | |
451 | (put 'calendar-holidays 'risky-local-variable t) | |
452 | ||
453 | ;;; End of user options. | |
454 | ||
455 | ||
d92bcf94 | 456 | ;; FIXME name that makes sense |
71855cc5 GM |
457 | ;;;###diary-autoload |
458 | (defun calendar-holiday-list () | |
459 | "Form the list of holidays that occur on dates in the calendar window. | |
460 | The holidays are those in the list `calendar-holidays'." | |
1dbf6332 GM |
461 | (let (res h) |
462 | (sort | |
463 | (dolist (p calendar-holidays res) | |
464 | (if (setq h (if calendar-debug-sexp | |
465 | (let ((stack-trace-on-error t)) | |
466 | (eval p)) | |
467 | (condition-case nil | |
468 | (eval p) | |
469 | (error (beep) | |
470 | (message "Bad holiday list item: %s" p) | |
471 | (sleep-for 2))))) | |
472 | (setq res (append h res)))) | |
473 | 'calendar-date-compare))) | |
71855cc5 | 474 | |
e803eab7 | 475 | (defvar displayed-month) ; from calendar-generate |
125001e9 GM |
476 | (defvar displayed-year) |
477 | ||
d92bcf94 | 478 | ;; FIXME name that makes sense |
71855cc5 | 479 | ;;;###cal-autoload |
436b840d | 480 | (defun calendar-list-holidays (&optional event) |
71855cc5 | 481 | "Create a buffer containing the holidays for the current calendar window. |
d600b865 | 482 | The holidays are those in the list `calendar-notable-days'. |
436b840d GM |
483 | Returns non-nil if any holidays are found. |
484 | If EVENT is non-nil, it's an event indicating the buffer position to | |
485 | use instead of point." | |
486 | (interactive (list last-nonmenu-event)) | |
487 | ;; If called from a menu, with the calendar window not selected. | |
488 | (with-current-buffer | |
489 | (if event (window-buffer (posn-window (event-start event))) | |
490 | (current-buffer)) | |
491 | (message "Looking up holidays...") | |
492 | (let ((holiday-list (calendar-holiday-list)) | |
493 | (m1 displayed-month) | |
494 | (y1 displayed-year) | |
495 | (m2 displayed-month) | |
496 | (y2 displayed-year)) | |
497 | (if (not holiday-list) | |
498 | (message "Looking up holidays...none found") | |
499 | (calendar-in-read-only-buffer holiday-buffer | |
500 | (calendar-increment-month m1 y1 -1) | |
501 | (calendar-increment-month m2 y2 1) | |
502 | (calendar-set-mode-line | |
503 | (if (= y1 y2) | |
504 | (format "Notable Dates from %s to %s, %d%%-" | |
505 | (calendar-month-name m1) (calendar-month-name m2) y2) | |
506 | (format "Notable Dates from %s, %d to %s, %d%%-" | |
507 | (calendar-month-name m1) y1 (calendar-month-name m2) y2))) | |
508 | (insert | |
509 | (mapconcat | |
510 | (lambda (x) (concat (calendar-date-string (car x)) | |
511 | ": " (cadr x))) | |
512 | holiday-list "\n"))) | |
513 | (message "Looking up holidays...done")) | |
514 | holiday-list))) | |
71855cc5 GM |
515 | |
516 | (define-obsolete-function-alias | |
517 | 'list-calendar-holidays 'calendar-list-holidays "23.1") | |
518 | ||
c8224de6 | 519 | ;;;###autoload |
7e1dae73 | 520 | (defun holidays (&optional arg) |
1802278a | 521 | "Display the holidays for last month, this month, and next month. |
68707926 | 522 | If called with an optional prefix argument ARG, prompts for month and year. |
1802278a | 523 | This function is suitable for execution in a .emacs file." |
7e1dae73 | 524 | (interactive "P") |
1802278a | 525 | (save-excursion |
7e1dae73 | 526 | (let* ((completion-ignore-case t) |
71855cc5 | 527 | (date (if arg (calendar-read-date t) |
c99d4526 | 528 | (calendar-current-date))) |
e803eab7 GM |
529 | (displayed-month (calendar-extract-month date)) |
530 | (displayed-year (calendar-extract-year date))) | |
2317a7cf | 531 | (calendar-list-holidays)))) |
1802278a | 532 | |
5fceaf9c GM |
533 | ;; rms: "Emacs commands to display a list of something generally start |
534 | ;; with `list-'. Please make `list-holidays' the principal name." | |
40b14a0c | 535 | ;;;###autoload |
96ffea61 | 536 | (defun list-holidays (y1 &optional y2 l label) |
056a21c4 | 537 | "Display holidays for years Y1 to Y2 (inclusive). |
f97492e5 GM |
538 | Y2 defaults to Y1. The optional list of holidays L defaults to |
539 | `calendar-holidays'. If you want to control what holidays are | |
540 | displayed, use a different list. For example, | |
29c83850 | 541 | |
5fceaf9c | 542 | (list-holidays 2006 2006 |
e803eab7 | 543 | (append holiday-general-holidays holiday-local-holidays)) |
29c83850 | 544 | |
e803eab7 | 545 | will display holidays for the year 2006 defined in the two |
29c83850 EZ |
546 | mentioned lists, and nothing else. |
547 | ||
cae09dea | 548 | When called interactively, this command offers a choice of |
e803eab7 | 549 | holidays, based on the variables `holiday-solar-holidays' etc. See the |
cae09dea GM |
550 | documentation of `calendar-holidays' for a list of the variables |
551 | that control the choices, as well as a description of the format | |
552 | of a holiday list. | |
056a21c4 RS |
553 | |
554 | The optional LABEL is used to label the buffer created." | |
555 | (interactive | |
556 | (let* ((start-year (calendar-read | |
557 | "Starting year of holidays (>0): " | |
b3a6c0ca | 558 | (lambda (x) (> x 0)) |
d92bcf94 | 559 | (number-to-string (calendar-extract-year |
056a21c4 RS |
560 | (calendar-current-date))))) |
561 | (end-year (calendar-read | |
71855cc5 GM |
562 | (format "Ending year (inclusive) of holidays (>=%s): " |
563 | start-year) | |
564 | (lambda (x) (>= x start-year)) | |
d92bcf94 | 565 | (number-to-string start-year))) |
056a21c4 RS |
566 | (completion-ignore-case t) |
567 | (lists | |
568 | (list | |
569 | (cons "All" calendar-holidays) | |
7d58cf63 GM |
570 | (cons "Equinoxes/Solstices" |
571 | (list (list 'solar-equinoxes-solstices))) | |
e803eab7 GM |
572 | (if holiday-general-holidays |
573 | (cons "General" holiday-general-holidays)) | |
574 | (if holiday-local-holidays | |
575 | (cons "Local" holiday-local-holidays)) | |
576 | (if holiday-other-holidays | |
577 | (cons "Other" holiday-other-holidays)) | |
578 | (if holiday-christian-holidays | |
579 | (cons "Christian" holiday-christian-holidays)) | |
580 | (if holiday-hebrew-holidays | |
581 | (cons "Hebrew" holiday-hebrew-holidays)) | |
582 | (if holiday-islamic-holidays | |
583 | (cons "Islamic" holiday-islamic-holidays)) | |
584 | (if holiday-bahai-holidays | |
585 | (cons "Baha'i" holiday-bahai-holidays)) | |
586 | (if holiday-oriental-holidays | |
587 | (cons "Oriental" holiday-oriental-holidays)) | |
588 | (if holiday-solar-holidays | |
589 | (cons "Solar" holiday-solar-holidays)) | |
056a21c4 RS |
590 | (cons "Ask" nil))) |
591 | (choice (capitalize | |
592 | (completing-read "List (TAB for choices): " lists nil t))) | |
593 | (which (if (string-equal choice "Ask") | |
594 | (eval (read-variable "Enter list name: ")) | |
595 | (cdr (assoc choice lists)))) | |
596 | (name (if (string-equal choice "Equinoxes/Solstices") | |
597 | choice | |
ebad70de | 598 | (if (member choice '("Ask" "")) |
a1506d29 | 599 | "Holidays" |
056a21c4 RS |
600 | (format "%s Holidays" choice))))) |
601 | (list start-year end-year which name))) | |
96ffea61 | 602 | (unless y2 (setq y2 y1)) |
056a21c4 | 603 | (message "Computing holidays...") |
d600b865 GM |
604 | (let ((calendar-holidays (or l calendar-holidays)) |
605 | (title (or label "Holidays")) | |
606 | (s (calendar-absolute-from-gregorian (list 2 1 y1))) | |
607 | (e (calendar-absolute-from-gregorian (list 11 1 y2))) | |
608 | (displayed-month 2) | |
609 | (displayed-year y1) | |
610 | holiday-list) | |
611 | (while (<= s e) | |
612 | (setq holiday-list (append holiday-list (calendar-holiday-list))) | |
e803eab7 | 613 | (calendar-increment-month displayed-month displayed-year 3) |
d600b865 | 614 | (setq s (calendar-absolute-from-gregorian |
056a21c4 | 615 | (list displayed-month 1 displayed-year)))) |
ebad70de | 616 | (save-excursion |
9449f9eb GM |
617 | (calendar-in-read-only-buffer holiday-buffer |
618 | (calendar-set-mode-line | |
619 | (if (= y1 y2) | |
620 | (format "%s for %s" title y1) | |
621 | (format "%s for %s-%s" title y1 y2))) | |
622 | (insert | |
623 | (mapconcat | |
624 | (lambda (x) (concat (calendar-date-string (car x)) | |
625 | ": " (cadr x))) | |
626 | holiday-list "\n"))) | |
ebad70de RS |
627 | (message "Computing holidays...done")))) |
628 | ||
c0dac68f | 629 | ;;;###autoload |
5fceaf9c | 630 | (defalias 'holiday-list 'list-holidays) |
056a21c4 | 631 | |
4ca17d75 | 632 | ;;;###diary-autoload |
2317a7cf | 633 | (defun calendar-check-holidays (date) |
1802278a JB |
634 | "Check the list of holidays for any that occur on DATE. |
635 | The value returned is a list of strings of relevant holiday descriptions. | |
2317a7cf | 636 | The holidays are those in the list `calendar-holidays'." |
e803eab7 GM |
637 | (let ((displayed-month (calendar-extract-month date)) |
638 | (displayed-year (calendar-extract-year date)) | |
d600b865 GM |
639 | holiday-list) |
640 | (dolist (h (calendar-holiday-list) holiday-list) | |
2317a7cf | 641 | (if (calendar-date-equal date (car h)) |
d600b865 | 642 | (setq holiday-list (append holiday-list (cdr h))))))) |
1802278a | 643 | |
71855cc5 GM |
644 | (define-obsolete-function-alias |
645 | 'check-calendar-holidays 'calendar-check-holidays "23.1") | |
646 | ||
e8a11b22 | 647 | (declare-function x-popup-menu "menu.c" (position menu)) |
f2d9c15f | 648 | |
4ca17d75 | 649 | ;;;###cal-autoload |
3b7de42e | 650 | (defun calendar-cursor-holidays (&optional date event) |
f1eb28f2 GM |
651 | "Find holidays for the date specified by the cursor in the calendar window. |
652 | Optional DATE is a list (month day year) to use instead of the | |
3b7de42e GM |
653 | cursor position. EVENT specifies a buffer position to use for a date." |
654 | (interactive (list nil last-nonmenu-event)) | |
1802278a | 655 | (message "Checking holidays...") |
3b7de42e GM |
656 | (or date (setq date (calendar-cursor-to-date t event))) |
657 | (let ((date-string (calendar-date-string date)) | |
658 | (holiday-list (calendar-check-holidays date)) | |
659 | selection msg) | |
660 | (if (mouse-event-p event) | |
661 | (and (setq selection (cal-menu-x-popup-menu event | |
662 | (format "Holidays for %s" date-string) | |
663 | (if holiday-list | |
664 | (mapcar 'list holiday-list) | |
665 | '("None")))) | |
666 | (call-interactively selection)) | |
1802278a JB |
667 | (if (not holiday-list) |
668 | (message "No holidays known for %s" date-string) | |
3b7de42e GM |
669 | (if (<= (length (setq msg |
670 | (format "%s: %s" date-string | |
671 | (mapconcat 'identity holiday-list "; ")))) | |
672 | (frame-width)) | |
eec5a2e4 | 673 | (message "%s" msg) |
9449f9eb GM |
674 | (calendar-in-read-only-buffer holiday-buffer |
675 | (calendar-set-mode-line date-string) | |
676 | (insert (mapconcat 'identity holiday-list "\n"))) | |
3b7de42e | 677 | (message "Checking holidays...done")))))) |
1802278a | 678 | |
d92bcf94 | 679 | ;; FIXME move to calendar? |
4ca17d75 | 680 | ;;;###cal-autoload |
436b840d GM |
681 | (defun calendar-mark-holidays (&optional event) |
682 | "Mark notable days in the calendar window. | |
683 | If EVENT is non-nil, it's an event indicating the buffer position to | |
684 | use instead of point." | |
685 | (interactive (list last-nonmenu-event)) | |
686 | ;; If called from a menu, with the calendar window not selected. | |
687 | (with-current-buffer | |
688 | (if event (window-buffer (posn-window (event-start event))) | |
689 | (current-buffer)) | |
690 | (setq calendar-mark-holidays-flag t) | |
691 | (message "Marking holidays...") | |
692 | (dolist (holiday (calendar-holiday-list)) | |
693 | (calendar-mark-visible-date (car holiday) calendar-holiday-marker)) | |
694 | (message "Marking holidays...done"))) | |
1802278a | 695 | |
71855cc5 GM |
696 | (define-obsolete-function-alias |
697 | 'mark-calendar-holidays 'calendar-mark-holidays "23.1") | |
1802278a JB |
698 | |
699 | ;; Below are the functions that calculate the dates of holidays; these | |
8ec105a0 JB |
700 | ;; are eval'ed in the function calendar-holiday-list. If you |
701 | ;; write other such functions, be sure to imitate the style used below. | |
702 | ;; Remember that each function must return a list of items of the form | |
703 | ;; ((month day year) string) of VISIBLE dates in the calendar window. | |
704 | ||
705 | (defun holiday-fixed (month day string) | |
706 | "Holiday on MONTH, DAY (Gregorian) called STRING. | |
707 | If MONTH, DAY is visible, the value returned is the list (((MONTH DAY year) | |
708 | STRING)). Returns nil if it is not visible in the current calendar window." | |
c8a54cf1 GM |
709 | ;; This determines whether a given month is visible in the calendar. |
710 | ;; cf calendar-date-is-visible-p (which also checks the year part). | |
711 | ;; The day is irrelevant since only full months are displayed. | |
712 | ;; Since the calendar displays three months at a time, month N | |
713 | ;; is visible if displayed-month = N-1, N, N+1. | |
714 | ;; In particular, November is visible if d-m = 10, 11, 12. | |
715 | ;; This is useful, because we can do a one-sided test: | |
716 | ;; November is visible if d-m > 9. (Similarly, February is visible if | |
717 | ;; d-m < 4.) | |
718 | ;; To determine if December is visible, we can shift the calendar | |
719 | ;; back a month and ask if November is visible; to determine if | |
720 | ;; October is visible, we can shift it forward a month and ask if | |
721 | ;; November is visible; etc. | |
8ec105a0 JB |
722 | (let ((m displayed-month) |
723 | (y displayed-year)) | |
e803eab7 | 724 | (calendar-increment-month m y (- 11 month)) |
c8a54cf1 | 725 | (if (> m 9) ; is november visible? |
71855cc5 | 726 | (list (list (list month day y) string))))) |
1802278a | 727 | |
8ec105a0 | 728 | (defun holiday-float (month dayname n string &optional day) |
5d595461 GM |
729 | "Holiday called STRING on the Nth DAYNAME after/before MONTH DAY. |
730 | DAYNAME=0 means Sunday, DAYNAME=1 means Monday, and so on. | |
731 | If N>0, use the Nth DAYNAME after MONTH DAY. | |
732 | If N<0, use the Nth DAYNAME before MONTH DAY. | |
733 | DAY defaults to 1 if N>0, and MONTH's last day otherwise. | |
734 | If the holiday is visible in the calendar window, returns a | |
735 | list (((month day year) STRING)). Otherwise returns nil." | |
d600b865 GM |
736 | ;; This is messy because the holiday may be visible, while the date |
737 | ;; on which it is based is not. For example, the first Monday after | |
738 | ;; December 30 may be visible when January is not. For large values | |
739 | ;; of |n| the problem is more grotesque. If we didn't have to worry | |
740 | ;; about such cases, we could just use the original version of this | |
741 | ;; function: | |
71855cc5 GM |
742 | ;; (let ((m displayed-month) |
743 | ;; (y displayed-year)) | |
e803eab7 | 744 | ;; (calendar-increment-month m y (- 11 month)) |
71855cc5 GM |
745 | ;; (if (> m 9); month in year y is visible |
746 | ;; (list (list (calendar-nth-named-day n dayname month y day) string))))) | |
151eeaa7 RS |
747 | (let* ((m1 displayed-month) |
748 | (y1 displayed-year) | |
d600b865 GM |
749 | (m2 displayed-month) |
750 | (y2 displayed-year) | |
751 | (d1 (progn ; first possible base date for holiday | |
e803eab7 | 752 | (calendar-increment-month m1 y1 -1) |
d600b865 GM |
753 | (+ (calendar-nth-named-absday 1 dayname m1 y1) |
754 | (* -7 n) | |
755 | (if (> n 0) 1 -7)))) | |
756 | (d2 ; last possible base date for holiday | |
757 | (progn | |
e803eab7 | 758 | (calendar-increment-month m2 y2 1) |
151eeaa7 RS |
759 | (+ (calendar-nth-named-absday -1 dayname m2 y2) |
760 | (* -7 n) | |
d600b865 | 761 | (if (> n 0) 7 -1)))) |
e803eab7 GM |
762 | (y1 (calendar-extract-year (calendar-gregorian-from-absolute d1))) |
763 | (y2 (calendar-extract-year (calendar-gregorian-from-absolute d2))) | |
d600b865 GM |
764 | (y ; year of base date |
765 | (if (or (= y1 y2) (> month 9)) | |
766 | y1 | |
767 | y2)) | |
768 | (d ; day of base date | |
769 | (or day (if (> n 0) | |
770 | 1 | |
771 | (calendar-last-day-of-month month y)))) | |
772 | (date ; base date for holiday | |
773 | (calendar-absolute-from-gregorian (list month d y)))) | |
774 | (and (<= d1 date) (<= date d2) | |
775 | (list (list (calendar-nth-named-day n dayname month y d) | |
776 | string))))) | |
8ec105a0 | 777 | |
1dbf6332 GM |
778 | (defun holiday-filter-visible-calendar (hlist) |
779 | "Filter list of holidays HLIST, and return only the visible ones. | |
780 | HLIST is a list of elements of the form (DATE) TEXT." | |
781 | (delq nil (mapcar (lambda (p) | |
782 | (and (car p) (calendar-date-is-visible-p (car p)) p)) | |
783 | hlist))) | |
71855cc5 GM |
784 | |
785 | (define-obsolete-function-alias | |
786 | 'filter-visible-calendar-holidays 'holiday-filter-visible-calendar "23.1") | |
787 | ||
8ec105a0 | 788 | (defun holiday-sexp (sexp string) |
7e1dae73 | 789 | "Sexp holiday for dates in the calendar window. |
d600b865 GM |
790 | SEXP is an expression in variable `year' that is evaluated to |
791 | give `date'. STRING is an expression in `date' that evaluates to | |
792 | the holiday description of `date'. If `date' is visible in the | |
793 | calendar window, the holiday STRING is on that date. If date is | |
794 | nil, or if the date is not visible, there is no holiday." | |
7e1dae73 | 795 | (let ((m displayed-month) |
d600b865 GM |
796 | (y displayed-year) |
797 | year date) | |
e803eab7 | 798 | (calendar-increment-month m y -1) |
2317a7cf SM |
799 | (holiday-filter-visible-calendar |
800 | (list | |
d600b865 GM |
801 | (progn |
802 | (setq year y | |
803 | date (eval sexp)) | |
804 | (list date (if date (eval string)))) | |
805 | (progn | |
806 | (setq year (1+ y) | |
807 | date (eval sexp)) | |
808 | (list date (if date (eval string)))))))) | |
809 | ||
8ec105a0 | 810 | |
92dd6c93 GM |
811 | (defun holiday-advent (&optional n string) |
812 | "Date of Nth day after advent (named STRING), if visible in calendar window. | |
813 | Negative values of N are interpreted as days before advent. | |
814 | STRING is used purely for display purposes. The return value has | |
815 | the form ((MONTH DAY YEAR) STRING), where the date is that of the | |
816 | Nth day before or after advent. | |
817 | ||
8dad6f62 | 818 | For backwards compatibility, if this function is called with no |
92dd6c93 | 819 | arguments, then it returns the value appropriate for advent itself." |
8dad6f62 | 820 | ;; Backwards compatibility layer. |
92dd6c93 GM |
821 | (if (not n) |
822 | (holiday-advent 0 "Advent") | |
d600b865 GM |
823 | (let* ((year displayed-year) |
824 | (month displayed-month) | |
825 | (advent (progn | |
e803eab7 | 826 | (calendar-increment-month month year -1) |
d600b865 GM |
827 | (calendar-gregorian-from-absolute |
828 | (+ n | |
829 | (calendar-dayname-on-or-before | |
830 | 0 | |
831 | (calendar-absolute-from-gregorian | |
832 | (list 12 3 year)))))))) | |
833 | (if (calendar-date-is-visible-p advent) | |
834 | (list (list advent string)))))) | |
1a499493 | 835 | |
3cd74de7 GM |
836 | (defun holiday-easter-etc (&optional n string) |
837 | "Date of Nth day after Easter (named STRING), if visible in calendar window. | |
838 | Negative values of N are interpreted as days before Easter. | |
839 | STRING is used purely for display purposes. The return value has | |
840 | the form ((MONTH DAY YEAR) STRING), where the date is that of the | |
841 | Nth day before or after Easter. | |
842 | ||
8dad6f62 | 843 | For backwards compatibility, if this function is called with no |
3cd74de7 | 844 | arguments, then it returns a list of \"standard\" Easter-related |
1c76c939 | 845 | holidays (with more entries if `calendar-christian-all-holidays-flag' |
3cd74de7 | 846 | is non-nil)." |
8dad6f62 | 847 | ;; Backwards compatibility layer. |
3cd74de7 | 848 | (if (not n) |
1dbf6332 GM |
849 | (apply 'append |
850 | (mapcar (lambda (e) | |
851 | (apply 'holiday-easter-etc e)) | |
852 | ;; The combined list is not in order. | |
853 | (append | |
1c76c939 | 854 | (if calendar-christian-all-holidays-flag |
1dbf6332 GM |
855 | '((-63 "Septuagesima Sunday") |
856 | (-56 "Sexagesima Sunday") | |
857 | (-49 "Shrove Sunday") | |
858 | (-48 "Shrove Monday") | |
859 | (-47 "Shrove Tuesday") | |
860 | (-14 "Passion Sunday") | |
861 | (-7 "Palm Sunday") | |
862 | (-3 "Maundy Thursday") | |
863 | (35 "Rogation Sunday") | |
864 | (39 "Ascension Day") | |
865 | (49 "Pentecost (Whitsunday)") | |
866 | (50 "Whitmonday") | |
867 | (56 "Trinity Sunday") | |
868 | (60 "Corpus Christi"))) | |
869 | '((-46 "Ash Wednesday") | |
870 | (-2 "Good Friday") | |
871 | (0 "Easter Sunday"))))) | |
3cd74de7 | 872 | (let* ((century (1+ (/ displayed-year 100))) |
7e2f1bb5 | 873 | (shifted-epact ; age of moon for April 5... |
125001e9 | 874 | (% (+ 14 (* 11 (% displayed-year 19)) ; ...by Nicaean rule |
7e2f1bb5 | 875 | (- ; ...corrected for the Gregorian century rule |
3cd74de7 | 876 | (/ (* 3 century) 4)) |
71855cc5 | 877 | (/ ; ...corrected for Metonic cycle inaccuracy |
3cd74de7 | 878 | (+ 5 (* 8 century)) 25) |
125001e9 | 879 | (* 30 century)) ; keeps value positive |
3cd74de7 | 880 | 30)) |
125001e9 | 881 | (adjusted-epact ; adjust for 29.5 day month |
3cd74de7 GM |
882 | (if (or (zerop shifted-epact) |
883 | (and (= shifted-epact 1) (< 10 (% displayed-year 19)))) | |
884 | (1+ shifted-epact) | |
885 | shifted-epact)) | |
7e2f1bb5 | 886 | (paschal-moon ; day after the full moon on or after March 21 |
3cd74de7 GM |
887 | (- (calendar-absolute-from-gregorian (list 4 19 displayed-year)) |
888 | adjusted-epact)) | |
1dbf6332 GM |
889 | (abs-easter (calendar-dayname-on-or-before 0 (+ paschal-moon 7))) |
890 | (greg (calendar-gregorian-from-absolute (+ abs-easter n)))) | |
891 | (if (calendar-date-is-visible-p greg) | |
892 | (list (list greg string)))))) | |
1802278a | 893 | |
cfe199f6 | 894 | ;; Prior call to calendar-julian-from-absolute will autoload cal-julian. |
5c645a20 | 895 | (declare-function calendar-julian-to-absolute "cal-julian" (date)) |
cfe199f6 | 896 | |
8ec105a0 JB |
897 | (defun holiday-greek-orthodox-easter () |
898 | "Date of Easter according to the rule of the Council of Nicaea." | |
d600b865 GM |
899 | (let* ((m displayed-month) |
900 | (y displayed-year) | |
901 | (julian-year (progn | |
e803eab7 GM |
902 | (calendar-increment-month m y 1) |
903 | (calendar-extract-year | |
d600b865 GM |
904 | (calendar-julian-from-absolute |
905 | (calendar-absolute-from-gregorian | |
906 | (list m (calendar-last-day-of-month m y) y)))))) | |
907 | (shifted-epact ; age of moon for April 5 | |
908 | (% (+ 14 | |
909 | (* 11 (% julian-year 19))) | |
910 | 30)) | |
911 | (paschal-moon ; day after full moon on or after March 21 | |
5c645a20 | 912 | (- (calendar-julian-to-absolute (list 4 19 julian-year)) |
d600b865 GM |
913 | shifted-epact)) |
914 | (nicaean-easter ; Sunday following the Paschal moon | |
915 | (calendar-gregorian-from-absolute | |
916 | (calendar-dayname-on-or-before 0 (+ paschal-moon 7))))) | |
917 | (if (calendar-date-is-visible-p nicaean-easter) | |
918 | (list (list nicaean-easter "Pascha (Greek Orthodox Easter)"))))) | |
7e1dae73 | 919 | |
49116ac0 JB |
920 | (provide 'holidays) |
921 | ||
1a06eabd | 922 | ;;; holidays.el ends here |