Mercurial > emacs
annotate lisp/calendar/holidays.el @ 778:cd00bdacc17b
*** empty log message ***
author | Jim Blandy <jimb@redhat.com> |
---|---|
date | Wed, 15 Jul 1992 02:24:58 +0000 |
parents | a8d94735277e |
children | 6fb68a1460a6 |
rev | line source |
---|---|
660
08eb386dd0f3
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
584
diff
changeset
|
1 ;;; holidays.el --- holiday functions for the calendar package |
732 | 2 ;;; Copyright (C) 1989, 1990 Free Software Foundation, Inc. |
406 | 3 |
4 ;; This file is part of GNU Emacs. | |
5 | |
6 ;; GNU Emacs is distributed in the hope that it will be useful, | |
7 ;; but WITHOUT ANY WARRANTY. No author or distributor | |
8 ;; accepts responsibility to anyone for the consequences of using it | |
9 ;; or for whether it serves any particular purpose or works at all, | |
10 ;; unless he says so in writing. Refer to the GNU Emacs General Public | |
11 ;; License for full details. | |
12 | |
13 ;; Everyone is granted permission to copy, modify and redistribute | |
14 ;; GNU Emacs, but only under the conditions described in the | |
15 ;; GNU Emacs General Public License. A copy of this license is | |
16 ;; supposed to have been given to you along with GNU Emacs so you | |
17 ;; can know your rights and responsibilities. It should be in a | |
18 ;; file named COPYING. Among other things, the copyright notice | |
19 ;; and this notice must be preserved on all copies. | |
20 | |
21 ;; This collection of functions implements the holiday features as described | |
22 ;; in calendar.el. | |
23 | |
24 ;; Comments, corrections, and improvements should be sent to | |
25 ;; Edward M. Reingold Department of Computer Science | |
26 ;; (217) 333-6733 University of Illinois at Urbana-Champaign | |
27 ;; reingold@cs.uiuc.edu 1304 West Springfield Avenue | |
28 ;; Urbana, Illinois 61801 | |
29 | |
30 ;; Technical details of all the calendrical calculations can be found in | |
31 ;; ``Calendrical Calculations'' by Nachum Dershowitz and Edward M. Reingold, | |
32 ;; Software--Practice and Experience, Volume 20, Number 9 (September, 1990), | |
33 ;; pages 899-928. | |
34 | |
35 (require 'calendar) | |
732 | 36 |
37 ;;;###autoload | |
406 | 38 (defun holidays () |
39 "Display the holidays for last month, this month, and next month. | |
40 This function is suitable for execution in a .emacs file." | |
41 (interactive) | |
42 (save-excursion | |
43 (let* ((date (calendar-current-date)) | |
44 (displayed-month (extract-calendar-month date)) | |
45 (displayed-year (extract-calendar-year date))) | |
46 (list-calendar-holidays)))) | |
47 | |
48 (defun check-calendar-holidays (date) | |
49 "Check the list of holidays for any that occur on DATE. | |
50 The value returned is a list of strings of relevant holiday descriptions. | |
51 The holidays are those in the list calendar-holidays." | |
52 (let* ((displayed-month (extract-calendar-month date)) | |
53 (displayed-year (extract-calendar-year date)) | |
54 (h (calendar-holiday-list)) | |
55 (holiday-list)) | |
56 (while h | |
57 (if (calendar-date-equal date (car (car h))) | |
58 (setq holiday-list (append holiday-list (cdr (car h))))) | |
59 (setq h (cdr h))) | |
60 holiday-list)) | |
61 | |
62 (defun calendar-cursor-holidays () | |
63 "Find holidays for the date specified by the cursor in the calendar window." | |
64 (interactive) | |
65 (message "Checking holidays...") | |
732 | 66 (let* ((date (or (calendar-cursor-to-date) |
67 (error "Cursor is not on a date!"))) | |
406 | 68 (date-string (calendar-date-string date)) |
69 (holiday-list (check-calendar-holidays date)) | |
70 (holiday-string (mapconcat 'identity holiday-list "; ")) | |
71 (msg (format "%s: %s" date-string holiday-string))) | |
72 (if (not holiday-list) | |
73 (message "No holidays known for %s" date-string) | |
778 | 74 (if (<= (length msg) (frame-width)) |
406 | 75 (message msg) |
76 (set-buffer (get-buffer-create holiday-buffer)) | |
77 (setq buffer-read-only nil) | |
78 (setq mode-line-format | |
79 (format "--------------------------%s%%-" | |
80 date-string)) | |
81 (erase-buffer) | |
82 (insert (mapconcat 'identity holiday-list "\n")) | |
83 (goto-char (point-min)) | |
84 (set-buffer-modified-p nil) | |
85 (setq buffer-read-only t) | |
86 (display-buffer holiday-buffer) | |
87 (message "Checking holidays...done"))))) | |
88 | |
89 (defun mark-calendar-holidays () | |
90 "Mark notable days in the calendar window." | |
91 (interactive) | |
92 (setq mark-holidays-in-calendar t) | |
93 (message "Marking holidays...") | |
94 (let ((holiday-list (calendar-holiday-list))) | |
95 (while holiday-list | |
96 (mark-visible-calendar-date | |
97 (car (car holiday-list)) calendar-holiday-marker) | |
98 (setq holiday-list (cdr holiday-list)))) | |
99 (message "Marking holidays...done")) | |
100 | |
101 (defun list-calendar-holidays () | |
102 "Create a buffer containing the holidays for the current calendar window. | |
103 The holidays are those in the list calendar-notable-days. Returns t if any | |
104 holidays are found, nil if not." | |
105 (interactive) | |
106 (message "Looking up holidays...") | |
107 (let ((holiday-list (calendar-holiday-list)) | |
108 (m1 displayed-month) | |
109 (y1 displayed-year) | |
110 (m2 displayed-month) | |
111 (y2 displayed-year)) | |
112 (if (not holiday-list) | |
113 (progn | |
114 (message "Looking up holidays...none found") | |
115 nil) | |
116 (set-buffer (get-buffer-create holiday-buffer)) | |
117 (setq buffer-read-only nil) | |
118 (increment-calendar-month m1 y1 -1) | |
119 (increment-calendar-month m2 y2 1) | |
120 (setq mode-line-format | |
121 (format "-------------Notable Dates from %s, %d to %s, %d%%-" | |
122 (calendar-month-name m1) y1 (calendar-month-name m2) y2)) | |
123 (erase-buffer) | |
124 (insert | |
125 (mapconcat | |
126 '(lambda (x) (concat (calendar-date-string (car x)) | |
127 ": " (car (cdr x)))) | |
128 holiday-list "\n")) | |
129 (goto-char (point-min)) | |
130 (set-buffer-modified-p nil) | |
131 (setq buffer-read-only t) | |
132 (display-buffer holiday-buffer) | |
133 (message "Looking up holidays...done") | |
134 t))) | |
135 | |
136 (defun calendar-holiday-list () | |
137 "Form the list of holidays that occur on dates in the calendar window. | |
138 The holidays are those in the list calendar-holidays." | |
139 (let ((p calendar-holidays) | |
140 (holiday-list)) | |
141 (while p | |
142 (let* ((function-name | |
143 (intern (format "calendar-holiday-function-%s" (car (car p))))) | |
144 (holidays | |
145 (if (cdr (car p));; optional arguments | |
146 (funcall function-name (cdr (car p))) | |
147 (funcall function-name)))) | |
148 (if holidays | |
149 (setq holiday-list (append holidays holiday-list)))) | |
150 (setq p (cdr p))) | |
151 (setq holiday-list (sort holiday-list 'calendar-date-compare)))) | |
152 | |
153 ;; Below are the functions that calculate the dates of holidays; these | |
154 ;; are called by the funcall in the function calendar-holiday-list. If you | |
155 ;; write other such functions, be sure to imitate the style used below, | |
156 ;; including the evaluation of each element in the list that constitutes | |
157 ;; the argument to the function. If you don't do this evaluation, the | |
158 ;; list calendar-holidays cannot contain expressions (as, for example, in | |
159 ;; the entry for the Islamic new year. Also remember that each function | |
160 ;; must return a list of items of the form ((month day year) string); | |
161 ;; the date (month day year) should be visible in the calendar window. | |
162 | |
163 (defun calendar-holiday-function-fixed (x) | |
164 "Returns the corresponding Gregorian date, if visible in the window, to | |
165 month, year where month is (car X) and year is (car (cdr X)). If it is | |
166 visible, the value returned is the list (((month day year) string)) where | |
167 string is (car (nthcdr 2 X)). Returns nil if it is not visible in the | |
168 current calendar window." | |
169 (let* ((month (eval (car x))) | |
170 (day (eval (car (cdr x)))) | |
171 (string (eval (car (nthcdr 2 x)))) | |
172 (m displayed-month) | |
173 (y displayed-year)) | |
174 (increment-calendar-month m y (- 11 month)) | |
175 (if (> m 9) | |
176 (list (list (list month day y) string))))) | |
177 | |
178 (defun calendar-holiday-function-float (x) | |
179 "Returns the corresponding Gregorian date, if visible in the window, to the | |
180 n-th occurrence (negative counts from the end of the month) of dayname in | |
181 month, year where month is (car X), year is (car (cdr X)), n is | |
182 \(car \(nthcdr 2 X\)\). If it is visible, the value returned is the list | |
183 \(\(\(month day year)\ string\)\) where string is (car (nthcdr 3 X)). | |
184 Returns nil if it is not visible in the current calendar window." | |
185 (let* ((month (eval (car x))) | |
186 (dayname (eval (car (cdr x)))) | |
187 (n (eval (car (nthcdr 2 x)))) | |
188 (string (eval (car (nthcdr 3 x)))) | |
189 (m displayed-month) | |
190 (y displayed-year)) | |
191 (increment-calendar-month m y (- 11 month)) | |
192 (if (> m 9) | |
193 (list (list (calendar-nth-named-day n dayname month y) string))))) | |
194 | |
195 (defun calendar-holiday-function-julian (x) | |
196 "Returns the corresponding Gregorian date, if visible in the window, to the | |
197 Julian date month, year where month is (car X) and year is (car (cdr X)). | |
198 If it is visible, the value returned is the list (((month day year) string)) | |
199 where string is (car (nthcdr 2 X)). Returns nil if it is not visible in the | |
200 current calendar window." | |
201 (let* ((month (eval (car x))) | |
202 (day (eval (car (cdr x)))) | |
203 (string (eval (car (nthcdr 2 x)))) | |
204 (m1 displayed-month) | |
205 (y1 displayed-year) | |
206 (m2 displayed-month) | |
207 (y2 displayed-year) | |
208 (year)) | |
209 (increment-calendar-month m1 y1 -1) | |
210 (increment-calendar-month m2 y2 1) | |
211 (let* ((start-date (calendar-absolute-from-gregorian | |
212 (list m1 1 y1))) | |
213 (end-date (calendar-absolute-from-gregorian | |
214 (list m2 (calendar-last-day-of-month m2 y2) y2))) | |
215 (julian-start (calendar-julian-from-absolute start-date)) | |
216 (julian-end (calendar-julian-from-absolute end-date)) | |
217 (julian-y1 (extract-calendar-year julian-start)) | |
218 (julian-y2 (extract-calendar-year julian-end))) | |
219 (setq year (if (< 10 month) julian-y1 julian-y2)) | |
220 (let ((date (calendar-gregorian-from-absolute | |
221 (calendar-absolute-from-julian | |
222 (list month day year))))) | |
223 (if (calendar-date-is-visible-p date) | |
224 (list (list date string))))))) | |
225 | |
226 (defun calendar-holiday-function-islamic (x) | |
227 "Returns the corresponding Gregorian date, if visible in the window, to the | |
228 Islamic date month, day where month is (car X) and day is (car (cdr X)). | |
229 If it is visible, the value returned is the list (((month day year) string)) | |
230 where string is (car (nthcdr 2 X)). Returns nil if it is not visible in | |
231 the current calendar window." | |
232 (let* ((month (eval (car x))) | |
233 (day (eval (car (cdr x)))) | |
234 (string (eval (car (nthcdr 2 x)))) | |
235 (islamic-date (calendar-islamic-from-absolute | |
236 (calendar-absolute-from-gregorian | |
237 (list displayed-month 15 displayed-year)))) | |
238 (m (extract-calendar-month islamic-date)) | |
239 (y (extract-calendar-year islamic-date)) | |
240 (date)) | |
241 (if (< m 1) | |
242 nil;; Islamic calendar doesn't apply. | |
243 (increment-calendar-month m y (- 10 month)) | |
244 (if (> m 7);; Islamic date might be visible | |
245 (let ((date (calendar-gregorian-from-absolute | |
246 (calendar-absolute-from-islamic (list month day y))))) | |
247 (if (calendar-date-is-visible-p date) | |
248 (list (list date string)))))))) | |
249 | |
250 (defun calendar-holiday-function-hebrew (x) | |
251 "Returns the corresponding Gregorian date, if visible in the window, to the | |
252 Hebrew date month, day where month is (car X) and day is (car (cdr X)). | |
253 If it is visible, the value returned is the list (((month day year) string)) | |
254 where string is (car (nthcdr 2 X)). Returns nil if it is not visible in | |
255 the current calendar window." | |
256 (let* ((month (eval (car x))) | |
257 (day (eval (car (cdr x)))) | |
258 (string (eval (car (nthcdr 2 x))))) | |
259 (if (memq displayed-month;; This test is only to speed things up a bit; | |
260 (list ;; it works fine without the test too. | |
261 (if (< 11 month) (- month 11) (+ month 1)) | |
262 (if (< 10 month) (- month 10) (+ month 2)) | |
263 (if (< 9 month) (- month 9) (+ month 3)) | |
264 (if (< 8 month) (- month 8) (+ month 4)) | |
265 (if (< 7 month) (- month 7) (+ month 5)))) | |
266 (let ((m1 displayed-month) | |
267 (y1 displayed-year) | |
268 (m2 displayed-month) | |
269 (y2 displayed-year) | |
270 (year)) | |
271 (increment-calendar-month m1 y1 -1) | |
272 (increment-calendar-month m2 y2 1) | |
273 (let* ((start-date (calendar-absolute-from-gregorian | |
274 (list m1 1 y1))) | |
275 (end-date (calendar-absolute-from-gregorian | |
276 (list m2 (calendar-last-day-of-month m2 y2) y2))) | |
277 (hebrew-start (calendar-hebrew-from-absolute start-date)) | |
278 (hebrew-end (calendar-hebrew-from-absolute end-date)) | |
279 (hebrew-y1 (extract-calendar-year hebrew-start)) | |
280 (hebrew-y2 (extract-calendar-year hebrew-end))) | |
281 (setq year (if (< 6 month) hebrew-y2 hebrew-y1)) | |
282 (let ((date (calendar-gregorian-from-absolute | |
283 (calendar-absolute-from-hebrew | |
284 (list month day year))))) | |
285 (if (calendar-date-is-visible-p date) | |
286 (list (list date string))))))))) | |
287 | |
288 (defun calendar-holiday-function-if (x) | |
289 "Conditional holiday for dates in the calendar window. | |
290 The boolean condition is (car X). If t, the holiday (car (cdr X)) is | |
291 checked. If nil, the holiday (car (cdr (cdr X))), if there, is checked." | |
292 (let* ((boolean (eval (car x))) | |
293 (h (if boolean (car (cdr x)) (car (cdr (cdr x)))))) | |
294 (if h | |
295 (let* ((function-name | |
296 (intern (format "calendar-holiday-function-%s" (car h)))) | |
297 (holidays | |
298 (if (cdr h);; optional arguments | |
299 (funcall function-name (cdr h)) | |
300 (funcall function-name)))) | |
301 holidays)))) | |
302 | |
303 (defun calendar-holiday-function-advent () | |
304 "Date of Advent, if visible in calendar window." | |
305 (let ((year displayed-year) | |
306 (month displayed-month)) | |
307 (increment-calendar-month month year -1) | |
308 (let ((advent (calendar-gregorian-from-absolute | |
309 (calendar-dayname-on-or-before 0 | |
310 (calendar-absolute-from-gregorian | |
311 (list 12 3 year)))))) | |
312 (if (calendar-date-is-visible-p advent) | |
313 (list (list advent "Advent")))))) | |
314 | |
315 (defun calendar-holiday-function-easter-etc () | |
316 "List of dates related to Easter, as visible in calendar window." | |
317 (if (and (> displayed-month 5) (not all-christian-calendar-holidays)) | |
318 nil;; Ash Wednesday, Good Friday, and Easter are not visible. | |
319 (let* ((century (1+ (/ displayed-year 100))) | |
320 (shifted-epact ;; Age of moon for April 5... | |
321 (% (+ 14 (* 11 (% displayed-year 19));; ...by Nicaean rule | |
322 (- ;; ...corrected for the Gregorian century rule | |
323 (/ (* 3 century) 4)) | |
324 (/ ;; ...corrected for Metonic cycle inaccuracy. | |
325 (+ 5 (* 8 century)) 25) | |
326 (* 30 century));; Keeps value positive. | |
327 30)) | |
328 (adjusted-epact ;; Adjust for 29.5 day month. | |
329 (if (or (= shifted-epact 0) | |
330 (and (= shifted-epact 1) (< 10 (% displayed-year 19)))) | |
331 (1+ shifted-epact) | |
332 shifted-epact)) | |
333 (paschal-moon ;; Day after the full moon on or after March 21. | |
334 (- (calendar-absolute-from-gregorian (list 4 19 displayed-year)) | |
335 adjusted-epact)) | |
336 (abs-easter (calendar-dayname-on-or-before 0 (+ paschal-moon 7))) | |
337 (mandatory | |
338 (list | |
339 (list (calendar-gregorian-from-absolute abs-easter) | |
340 "Easter Sunday") | |
341 (list (calendar-gregorian-from-absolute (- abs-easter 2)) | |
342 "Good Friday") | |
343 (list (calendar-gregorian-from-absolute (- abs-easter 46)) | |
344 "Ash Wednesday"))) | |
345 (optional | |
346 (list | |
347 (list (calendar-gregorian-from-absolute (- abs-easter 63)) | |
348 "Septuagesima Sunday") | |
349 (list (calendar-gregorian-from-absolute (- abs-easter 56)) | |
350 "Sexagesima Sunday") | |
351 (list (calendar-gregorian-from-absolute (- abs-easter 49)) | |
352 "Shrove Sunday") | |
353 (list (calendar-gregorian-from-absolute (- abs-easter 48)) | |
354 "Shrove Monday") | |
355 (list (calendar-gregorian-from-absolute (- abs-easter 47)) | |
356 "Shrove Tuesday") | |
357 (list (calendar-gregorian-from-absolute (- abs-easter 14)) | |
358 "Passion Sunday") | |
359 (list (calendar-gregorian-from-absolute (- abs-easter 7)) | |
360 "Palm Sunday") | |
361 (list (calendar-gregorian-from-absolute (- abs-easter 3)) | |
362 "Maundy Thursday") | |
363 (list (calendar-gregorian-from-absolute (+ abs-easter 35)) | |
364 "Rogation Sunday") | |
365 (list (calendar-gregorian-from-absolute (+ abs-easter 39)) | |
366 "Ascension Sunday") | |
367 (list (calendar-gregorian-from-absolute (+ abs-easter 49)) | |
368 "Pentecost (Whitsunday)") | |
369 (list (calendar-gregorian-from-absolute (+ abs-easter 50)) | |
370 "Whitmunday") | |
371 (list (calendar-gregorian-from-absolute (+ abs-easter 56)) | |
372 "Trinity Sunday") | |
373 (list (calendar-gregorian-from-absolute (+ abs-easter 60)) | |
374 "Corpus Christi"))) | |
375 (output-list | |
376 (filter-visible-calendar-holidays mandatory))) | |
377 (if all-christian-calendar-holidays | |
378 (setq output-list | |
379 (append | |
380 (filter-visible-calendar-holidays optional) | |
381 output-list))) | |
382 output-list))) | |
383 | |
384 (defun calendar-holiday-function-rosh-hashanah-etc () | |
385 "List of dates related to Rosh Hashanah, as visible in calendar window." | |
386 (if (or (< displayed-month 8) | |
387 (> displayed-month 11)) | |
388 nil;; None of the dates is visible | |
389 (let* ((abs-r-h (calendar-absolute-from-hebrew | |
390 (list 7 1 (+ displayed-year 3761)))) | |
391 (mandatory | |
392 (list | |
393 (list (calendar-gregorian-from-absolute abs-r-h) | |
394 (format "Rosh HaShanah %d" (+ 3761 displayed-year))) | |
395 (list (calendar-gregorian-from-absolute (+ abs-r-h 9)) | |
396 "Yom Kippur") | |
397 (list (calendar-gregorian-from-absolute (+ abs-r-h 14)) | |
398 "Sukkot") | |
399 (list (calendar-gregorian-from-absolute (+ abs-r-h 21)) | |
400 "Shemini Atzeret") | |
401 (list (calendar-gregorian-from-absolute (+ abs-r-h 22)) | |
402 "Simchat Torah"))) | |
403 (optional | |
404 (list | |
405 (list (calendar-gregorian-from-absolute | |
406 (calendar-dayname-on-or-before 6 (- abs-r-h 4))) | |
407 "Selichot (night)") | |
408 (list (calendar-gregorian-from-absolute (1- abs-r-h)) | |
409 "Erev Rosh HaShannah") | |
410 (list (calendar-gregorian-from-absolute (1+ abs-r-h)) | |
411 "Rosh HaShanah (second day)") | |
412 (list (calendar-gregorian-from-absolute | |
413 (if (= (% abs-r-h 7) 4) (+ abs-r-h 3) (+ abs-r-h 2))) | |
414 "Tzom Gedaliah") | |
415 (list (calendar-gregorian-from-absolute | |
416 (calendar-dayname-on-or-before 6 (+ 7 abs-r-h))) | |
417 "Shabbat Shuvah") | |
418 (list (calendar-gregorian-from-absolute (+ abs-r-h 8)) | |
419 "Erev Yom Kippur") | |
420 (list (calendar-gregorian-from-absolute (+ abs-r-h 13)) | |
421 "Erev Sukkot") | |
422 (list (calendar-gregorian-from-absolute (+ abs-r-h 15)) | |
423 "Sukkot (second day)") | |
424 (list (calendar-gregorian-from-absolute (+ abs-r-h 16)) | |
425 "Hol Hamoed Sukkot (first day)") | |
426 (list (calendar-gregorian-from-absolute (+ abs-r-h 17)) | |
427 "Hol Hamoed Sukkot (second day)") | |
428 (list (calendar-gregorian-from-absolute (+ abs-r-h 18)) | |
429 "Hol Hamoed Sukkot (third day)") | |
430 (list (calendar-gregorian-from-absolute (+ abs-r-h 19)) | |
431 "Hol Hamoed Sukkot (fourth day)") | |
432 (list (calendar-gregorian-from-absolute (+ abs-r-h 20)) | |
433 "Hoshannah Rabbah"))) | |
434 (output-list | |
435 (filter-visible-calendar-holidays mandatory))) | |
436 (if all-hebrew-calendar-holidays | |
437 (setq output-list | |
438 (append | |
439 (filter-visible-calendar-holidays optional) | |
440 output-list))) | |
441 output-list))) | |
442 | |
443 (defun calendar-holiday-function-hanukkah () | |
444 "List of dates related to Hanukkah, as visible in calendar window." | |
445 (if (memq displayed-month;; This test is only to speed things up a bit; | |
446 '(10 11 12 1 2));; it works fine without the test too. | |
447 (let ((m displayed-month) | |
448 (y displayed-year)) | |
449 (increment-calendar-month m y 1) | |
450 (let* ((h-y (extract-calendar-year | |
451 (calendar-hebrew-from-absolute | |
452 (calendar-absolute-from-gregorian | |
453 (list m (calendar-last-day-of-month m y) y))))) | |
454 (abs-h (calendar-absolute-from-hebrew (list 9 25 h-y)))) | |
455 (filter-visible-calendar-holidays | |
456 (list | |
457 (list (calendar-gregorian-from-absolute (1- abs-h)) | |
458 "Erev Hanukkah") | |
459 (list (calendar-gregorian-from-absolute abs-h) | |
460 "Hanukkah (first day)") | |
461 (list (calendar-gregorian-from-absolute (1+ abs-h)) | |
462 "Hanukkah (second day)") | |
463 (list (calendar-gregorian-from-absolute (+ abs-h 2)) | |
464 "Hanukkah (third day)") | |
465 (list (calendar-gregorian-from-absolute (+ abs-h 3)) | |
466 "Hanukkah (fourth day)") | |
467 (list (calendar-gregorian-from-absolute (+ abs-h 4)) | |
468 "Hanukkah (fifth day)") | |
469 (list (calendar-gregorian-from-absolute (+ abs-h 5)) | |
470 "Hanukkah (sixth day)") | |
471 (list (calendar-gregorian-from-absolute (+ abs-h 6)) | |
472 "Hanukkah (seventh day)") | |
473 (list (calendar-gregorian-from-absolute (+ abs-h 7)) | |
474 "Hanukkah (eighth day)"))))))) | |
475 | |
476 (defun calendar-holiday-function-passover-etc () | |
477 "List of dates related to Passover, as visible in calendar window." | |
478 (if (< 7 displayed-month) | |
479 nil;; None of the dates is visible | |
480 (let* ((abs-p (calendar-absolute-from-hebrew | |
481 (list 1 15 (+ displayed-year 3760)))) | |
482 (mandatory | |
483 (list | |
484 (list (calendar-gregorian-from-absolute abs-p) | |
485 "Passover") | |
486 (list (calendar-gregorian-from-absolute (+ abs-p 50)) | |
487 "Shavuot"))) | |
488 (optional | |
489 (list | |
490 (list (calendar-gregorian-from-absolute | |
491 (calendar-dayname-on-or-before 6 (- abs-p 43))) | |
492 "Shabbat Shekalim") | |
493 (list (calendar-gregorian-from-absolute | |
494 (calendar-dayname-on-or-before 6 (- abs-p 30))) | |
495 "Shabbat Zachor") | |
496 (list (calendar-gregorian-from-absolute | |
497 (if (= (% abs-p 7) 2) (- abs-p 33) (- abs-p 31))) | |
498 "Fast of Esther") | |
499 (list (calendar-gregorian-from-absolute (- abs-p 31)) | |
500 "Erev Purim") | |
501 (list (calendar-gregorian-from-absolute (- abs-p 30)) | |
502 "Purim") | |
503 (list (calendar-gregorian-from-absolute | |
504 (if (zerop (% abs-p 7)) (- abs-p 28) (- abs-p 29))) | |
505 "Shushan Purim") | |
506 (list (calendar-gregorian-from-absolute | |
507 (- (calendar-dayname-on-or-before 6 (- abs-p 14)) 7)) | |
508 "Shabbat Parah") | |
509 (list (calendar-gregorian-from-absolute | |
510 (calendar-dayname-on-or-before 6 (- abs-p 14))) | |
511 "Shabbat HaHodesh") | |
512 (list (calendar-gregorian-from-absolute | |
513 (calendar-dayname-on-or-before 6 (1- abs-p))) | |
514 "Shabbat HaGadol") | |
515 (list (calendar-gregorian-from-absolute (1- abs-p)) | |
516 "Erev Passover") | |
517 (list (calendar-gregorian-from-absolute (1+ abs-p)) | |
518 "Passover (second day)") | |
519 (list (calendar-gregorian-from-absolute (+ abs-p 2)) | |
520 "Hol Hamoed Passover (first day)") | |
521 (list (calendar-gregorian-from-absolute (+ abs-p 3)) | |
522 "Hol Hamoed Passover (second day)") | |
523 (list (calendar-gregorian-from-absolute (+ abs-p 4)) | |
524 "Hol Hamoed Passover (third day)") | |
525 (list (calendar-gregorian-from-absolute (+ abs-p 5)) | |
526 "Hol Hamoed Passover (fourth day)") | |
527 (list (calendar-gregorian-from-absolute (+ abs-p 6)) | |
528 "Passover (seventh day)") | |
529 (list (calendar-gregorian-from-absolute (+ abs-p 7)) | |
530 "Passover (eighth day)") | |
531 (list (calendar-gregorian-from-absolute (+ abs-p 12)) | |
532 "Yom HaShoah") | |
533 (list (calendar-gregorian-from-absolute | |
534 (if (zerop (% abs-p 7)) | |
535 (+ abs-p 18) | |
536 (if (= (% abs-p 7) 6) | |
537 (+ abs-p 19) | |
538 (+ abs-p 20)))) | |
539 "Yom HaAtzma'ut") | |
540 (list (calendar-gregorian-from-absolute (+ abs-p 33)) | |
541 "Lag BaOmer") | |
542 (list (calendar-gregorian-from-absolute (+ abs-p 43)) | |
543 "Yom Yerushalim") | |
544 (list (calendar-gregorian-from-absolute (+ abs-p 49)) | |
545 "Erev Shavuot") | |
546 (list (calendar-gregorian-from-absolute (+ abs-p 51)) | |
547 "Shavuot (second day)"))) | |
548 (output-list | |
549 (filter-visible-calendar-holidays mandatory))) | |
550 (if all-hebrew-calendar-holidays | |
551 (setq output-list | |
552 (append | |
553 (filter-visible-calendar-holidays optional) | |
554 output-list))) | |
555 output-list))) | |
556 | |
557 (defun calendar-holiday-function-tisha-b-av-etc () | |
558 "List of dates around Tisha B'Av, as visible in calendar window." | |
559 (if (or (< displayed-month 5) | |
560 (> displayed-month 9)) | |
561 nil;; None of the dates is visible | |
562 (let* ((abs-t-a (calendar-absolute-from-hebrew | |
563 (list 5 9 (+ displayed-year 3760))))) | |
564 | |
565 (filter-visible-calendar-holidays | |
566 (list | |
567 (list (calendar-gregorian-from-absolute | |
568 (if (= (% abs-t-a 7) 6) (- abs-t-a 20) (- abs-t-a 21))) | |
569 "Tzom Tammuz") | |
570 (list (calendar-gregorian-from-absolute | |
571 (calendar-dayname-on-or-before 6 abs-t-a)) | |
572 "Shabbat Hazon") | |
573 (list (calendar-gregorian-from-absolute | |
574 (if (= (% abs-t-a 7) 6) (1+ abs-t-a) abs-t-a)) | |
575 "Tisha B'Av") | |
576 (list (calendar-gregorian-from-absolute | |
577 (calendar-dayname-on-or-before 6 (+ abs-t-a 7))) | |
578 "Shabbat Nahamu")))))) | |
579 | |
580 (defun filter-visible-calendar-holidays (l) | |
581 "Return a list of all visible holidays of those on L." | |
582 (let ((visible) | |
583 (p l)) | |
584 (while p | |
585 (if (calendar-date-is-visible-p (car (car p))) | |
586 (setq visible (append (list (car p)) visible))) | |
587 (setq p (cdr p))) | |
588 visible)) | |
584 | 589 |
590 (provide 'holidays) | |
591 | |
660
08eb386dd0f3
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
584
diff
changeset
|
592 ;;; holidays.el ends here |