Mercurial > emacs
annotate lisp/calendar/holidays.el @ 6782:5b07647ec8f7
*** empty log message ***
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sun, 10 Apr 1994 00:23:58 +0000 |
parents | 3e1323443b1a |
children | cc7cd83ccf3f |
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 |
793
6fb68a1460a6
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
778
diff
changeset
|
2 |
5831
7a4647230b22
(calendar-cursor-holidays): Use new error arg
Richard M. Stallman <rms@gnu.org>
parents:
5696
diff
changeset
|
3 ;;; Copyright (C) 1989, 1990, 1992, 1993 Free Software Foundation, Inc. |
846
20674ae6bf52
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
811
diff
changeset
|
4 |
793
6fb68a1460a6
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
778
diff
changeset
|
5 ;; Author: Edward M. Reingold <reingold@cs.uiuc.edu> |
957 | 6 ;; Keywords: holidays, calendar |
793
6fb68a1460a6
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
778
diff
changeset
|
7 |
406 | 8 ;; This file is part of GNU Emacs. |
9 | |
6736
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
5831
diff
changeset
|
10 ;; GNU Emacs is free software; you can redistribute it and/or modify |
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
5831
diff
changeset
|
11 ;; it under the terms of the GNU General Public License as published by |
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
5831
diff
changeset
|
12 ;; the Free Software Foundation; either version 2, or (at your option) |
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
5831
diff
changeset
|
13 ;; any later version. |
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
14 |
406 | 15 ;; GNU Emacs is distributed in the hope that it will be useful, |
6736
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
5831
diff
changeset
|
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
5831
diff
changeset
|
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
5831
diff
changeset
|
18 ;; GNU General Public License for more details. |
406 | 19 |
6736
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
5831
diff
changeset
|
20 ;; You should have received a copy of the GNU General Public License |
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
5831
diff
changeset
|
21 ;; along with GNU Emacs; see the file COPYING. If not, write to |
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
5831
diff
changeset
|
22 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
406 | 23 |
793
6fb68a1460a6
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
778
diff
changeset
|
24 ;;; Commentary: |
6fb68a1460a6
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
778
diff
changeset
|
25 |
406 | 26 ;; This collection of functions implements the holiday features as described |
27 ;; in calendar.el. | |
28 | |
29 ;; Comments, corrections, and improvements should be sent to | |
30 ;; Edward M. Reingold Department of Computer Science | |
31 ;; (217) 333-6733 University of Illinois at Urbana-Champaign | |
32 ;; reingold@cs.uiuc.edu 1304 West Springfield Avenue | |
33 ;; Urbana, Illinois 61801 | |
34 | |
35 ;; Technical details of all the calendrical calculations can be found in | |
36 ;; ``Calendrical Calculations'' by Nachum Dershowitz and Edward M. Reingold, | |
37 ;; Software--Practice and Experience, Volume 20, Number 9 (September, 1990), | |
957 | 38 ;; pages 899-928. ``Calendrical Calculations, Part II: Three Historical |
39 ;; Calendars'' by E. M. Reingold, N. Dershowitz, and S. M. Clamen, | |
2945
2c1f0215fcc3
* holidays.el: Update reference to the papers in S-P&E.
Jim Blandy <jimb@redhat.com>
parents:
957
diff
changeset
|
40 ;; Software--Practice and Experience, Volume 23, Number 4 (April, 1993), |
2c1f0215fcc3
* holidays.el: Update reference to the papers in S-P&E.
Jim Blandy <jimb@redhat.com>
parents:
957
diff
changeset
|
41 ;; pages 383-404. |
957 | 42 |
43 ;; Hard copies of these two papers can be obtained by sending email to | |
44 ;; reingold@cs.uiuc.edu with the SUBJECT "send-paper-cal" (no quotes) and | |
45 ;; the message BODY containing your mailing address (snail). | |
406 | 46 |
793
6fb68a1460a6
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
778
diff
changeset
|
47 ;;; Code: |
6fb68a1460a6
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
778
diff
changeset
|
48 |
406 | 49 (require 'calendar) |
732 | 50 |
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
51 (autoload 'solar-equinoxes-solstices "solar" |
957 | 52 "Date and time of equinoxes and solstices, if visible in the calendar window. |
53 Requires floating point." | |
54 t) | |
55 | |
56 (defun holidays (&optional arg) | |
406 | 57 "Display the holidays for last month, this month, and next month. |
957 | 58 If called with an optional prefix argument, prompts for month and year. |
59 | |
406 | 60 This function is suitable for execution in a .emacs file." |
957 | 61 (interactive "P") |
406 | 62 (save-excursion |
957 | 63 (let* ((completion-ignore-case t) |
64 (date (calendar-current-date)) | |
65 (displayed-month | |
66 (if arg | |
67 (cdr (assoc | |
68 (capitalize | |
69 (completing-read | |
70 "Month name: " | |
71 (mapcar 'list (append calendar-month-name-array nil)) | |
72 nil t)) | |
73 (calendar-make-alist calendar-month-name-array))) | |
74 (extract-calendar-month date))) | |
75 (displayed-year | |
76 (if arg | |
77 (calendar-read | |
78 "Year (>0): " | |
79 '(lambda (x) (> x 0)) | |
80 (int-to-string | |
81 (extract-calendar-year (calendar-current-date)))) | |
82 (extract-calendar-year date)))) | |
406 | 83 (list-calendar-holidays)))) |
84 | |
85 (defun check-calendar-holidays (date) | |
86 "Check the list of holidays for any that occur on DATE. | |
87 The value returned is a list of strings of relevant holiday descriptions. | |
88 The holidays are those in the list calendar-holidays." | |
89 (let* ((displayed-month (extract-calendar-month date)) | |
90 (displayed-year (extract-calendar-year date)) | |
91 (h (calendar-holiday-list)) | |
92 (holiday-list)) | |
93 (while h | |
94 (if (calendar-date-equal date (car (car h))) | |
95 (setq holiday-list (append holiday-list (cdr (car h))))) | |
96 (setq h (cdr h))) | |
97 holiday-list)) | |
98 | |
99 (defun calendar-cursor-holidays () | |
100 "Find holidays for the date specified by the cursor in the calendar window." | |
101 (interactive) | |
102 (message "Checking holidays...") | |
5831
7a4647230b22
(calendar-cursor-holidays): Use new error arg
Richard M. Stallman <rms@gnu.org>
parents:
5696
diff
changeset
|
103 (let* ((date (calendar-cursor-to-date t)) |
406 | 104 (date-string (calendar-date-string date)) |
105 (holiday-list (check-calendar-holidays date)) | |
106 (holiday-string (mapconcat 'identity holiday-list "; ")) | |
107 (msg (format "%s: %s" date-string holiday-string))) | |
108 (if (not holiday-list) | |
109 (message "No holidays known for %s" date-string) | |
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
110 (if (<= (length msg) (frame-width)) |
406 | 111 (message msg) |
112 (set-buffer (get-buffer-create holiday-buffer)) | |
113 (setq buffer-read-only nil) | |
957 | 114 (calendar-set-mode-line date-string) |
406 | 115 (erase-buffer) |
116 (insert (mapconcat 'identity holiday-list "\n")) | |
117 (goto-char (point-min)) | |
118 (set-buffer-modified-p nil) | |
119 (setq buffer-read-only t) | |
120 (display-buffer holiday-buffer) | |
121 (message "Checking holidays...done"))))) | |
122 | |
123 (defun mark-calendar-holidays () | |
124 "Mark notable days in the calendar window." | |
125 (interactive) | |
126 (setq mark-holidays-in-calendar t) | |
127 (message "Marking holidays...") | |
128 (let ((holiday-list (calendar-holiday-list))) | |
129 (while holiday-list | |
130 (mark-visible-calendar-date | |
131 (car (car holiday-list)) calendar-holiday-marker) | |
132 (setq holiday-list (cdr holiday-list)))) | |
133 (message "Marking holidays...done")) | |
134 | |
135 (defun list-calendar-holidays () | |
136 "Create a buffer containing the holidays for the current calendar window. | |
137 The holidays are those in the list calendar-notable-days. Returns t if any | |
138 holidays are found, nil if not." | |
139 (interactive) | |
140 (message "Looking up holidays...") | |
141 (let ((holiday-list (calendar-holiday-list)) | |
142 (m1 displayed-month) | |
143 (y1 displayed-year) | |
144 (m2 displayed-month) | |
145 (y2 displayed-year)) | |
146 (if (not holiday-list) | |
147 (progn | |
148 (message "Looking up holidays...none found") | |
149 nil) | |
150 (set-buffer (get-buffer-create holiday-buffer)) | |
151 (setq buffer-read-only nil) | |
152 (increment-calendar-month m1 y1 -1) | |
153 (increment-calendar-month m2 y2 1) | |
957 | 154 (calendar-set-mode-line |
5696
baab03aaf3b9
(list-calendar-holidays): Fix mode line.
Richard M. Stallman <rms@gnu.org>
parents:
4864
diff
changeset
|
155 (if (= y1 y2) |
baab03aaf3b9
(list-calendar-holidays): Fix mode line.
Richard M. Stallman <rms@gnu.org>
parents:
4864
diff
changeset
|
156 (format "Notable Dates from %s to %s, %d%%-" |
baab03aaf3b9
(list-calendar-holidays): Fix mode line.
Richard M. Stallman <rms@gnu.org>
parents:
4864
diff
changeset
|
157 (calendar-month-name m1) (calendar-month-name m2) y2) |
baab03aaf3b9
(list-calendar-holidays): Fix mode line.
Richard M. Stallman <rms@gnu.org>
parents:
4864
diff
changeset
|
158 (format "Notable Dates from %s, %d to %s, %d%%-" |
baab03aaf3b9
(list-calendar-holidays): Fix mode line.
Richard M. Stallman <rms@gnu.org>
parents:
4864
diff
changeset
|
159 (calendar-month-name m1) y1 (calendar-month-name m2) y2))) |
406 | 160 (erase-buffer) |
161 (insert | |
162 (mapconcat | |
163 '(lambda (x) (concat (calendar-date-string (car x)) | |
164 ": " (car (cdr x)))) | |
165 holiday-list "\n")) | |
166 (goto-char (point-min)) | |
167 (set-buffer-modified-p nil) | |
168 (setq buffer-read-only t) | |
169 (display-buffer holiday-buffer) | |
170 (message "Looking up holidays...done") | |
171 t))) | |
172 | |
173 (defun calendar-holiday-list () | |
174 "Form the list of holidays that occur on dates in the calendar window. | |
175 The holidays are those in the list calendar-holidays." | |
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
176 (let ((p calendar-holidays) |
406 | 177 (holiday-list)) |
178 (while p | |
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
179 (let* ((holidays |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
180 (if calendar-debug-sexp |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
181 (let ((stack-trace-on-error t)) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
182 (eval (car p))) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
183 (condition-case nil |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
184 (eval (car p)) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
185 (error (beep) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
186 (message "Bad holiday list item: %s" (car p)) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
187 (sleep-for 2)))))) |
406 | 188 (if holidays |
189 (setq holiday-list (append holidays holiday-list)))) | |
190 (setq p (cdr p))) | |
191 (setq holiday-list (sort holiday-list 'calendar-date-compare)))) | |
192 | |
193 ;; Below are the functions that calculate the dates of holidays; these | |
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
194 ;; are eval'ed in the function calendar-holiday-list. If you |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
195 ;; write other such functions, be sure to imitate the style used below. |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
196 ;; Remember that each function must return a list of items of the form |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
197 ;; ((month day year) string) of VISIBLE dates in the calendar window. |
406 | 198 |
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
199 (defun holiday-fixed (month day string) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
200 "Holiday on MONTH, DAY (Gregorian) called STRING. |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
201 If MONTH, DAY is visible, the value returned is the list (((MONTH DAY year) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
202 STRING)). Returns nil if it is not visible in the current calendar window." |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
203 (let ((m displayed-month) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
204 (y displayed-year)) |
406 | 205 (increment-calendar-month m y (- 11 month)) |
206 (if (> m 9) | |
207 (list (list (list month day y) string))))) | |
208 | |
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
209 (defun holiday-float (month dayname n string &optional day) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
210 "Holiday on MONTH, DAYNAME (Nth occurrence, Gregorian) called STRING. |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
211 If the Nth DAYNAME in MONTH is visible, the value returned is the list |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
212 (((MONTH DAY year) STRING)). |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
213 |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
214 If N<0, count backward from the end of MONTH. |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
215 |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
216 An optional parameter DAY means the Nth DAYNAME after/before MONTH DAY. |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
217 |
406 | 218 Returns nil if it is not visible in the current calendar window." |
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
219 (let ((m displayed-month) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
220 (y displayed-year)) |
406 | 221 (increment-calendar-month m y (- 11 month)) |
222 (if (> m 9) | |
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
223 (list (list (calendar-nth-named-day n dayname month y day) string))))) |
406 | 224 |
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
225 (defun holiday-julian (month day string) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
226 "Holiday on MONTH, DAY (Julian) called STRING. |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
227 If MONTH, DAY (Julian) is visible, the value returned is corresponding |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
228 Gregorian date in the form of the list (((month day year) STRING)). Returns |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
229 nil if it is not visible in the current calendar window." |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
230 (let ((m1 displayed-month) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
231 (y1 displayed-year) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
232 (m2 displayed-month) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
233 (y2 displayed-year) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
234 (year)) |
406 | 235 (increment-calendar-month m1 y1 -1) |
236 (increment-calendar-month m2 y2 1) | |
237 (let* ((start-date (calendar-absolute-from-gregorian | |
238 (list m1 1 y1))) | |
239 (end-date (calendar-absolute-from-gregorian | |
240 (list m2 (calendar-last-day-of-month m2 y2) y2))) | |
241 (julian-start (calendar-julian-from-absolute start-date)) | |
242 (julian-end (calendar-julian-from-absolute end-date)) | |
243 (julian-y1 (extract-calendar-year julian-start)) | |
244 (julian-y2 (extract-calendar-year julian-end))) | |
245 (setq year (if (< 10 month) julian-y1 julian-y2)) | |
246 (let ((date (calendar-gregorian-from-absolute | |
247 (calendar-absolute-from-julian | |
248 (list month day year))))) | |
249 (if (calendar-date-is-visible-p date) | |
250 (list (list date string))))))) | |
251 | |
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
252 (defun holiday-islamic (month day string) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
253 "Holiday on MONTH, DAY (Islamic) called STRING. |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
254 If MONTH, DAY (Islamic) is visible, the value returned is corresponding |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
255 Gregorian date in the form of the list (((month day year) STRING)). Returns |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
256 nil if it is not visible in the current calendar window." |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
257 (let* ((islamic-date (calendar-islamic-from-absolute |
406 | 258 (calendar-absolute-from-gregorian |
259 (list displayed-month 15 displayed-year)))) | |
260 (m (extract-calendar-month islamic-date)) | |
261 (y (extract-calendar-year islamic-date)) | |
262 (date)) | |
263 (if (< m 1) | |
264 nil;; Islamic calendar doesn't apply. | |
265 (increment-calendar-month m y (- 10 month)) | |
266 (if (> m 7);; Islamic date might be visible | |
267 (let ((date (calendar-gregorian-from-absolute | |
268 (calendar-absolute-from-islamic (list month day y))))) | |
269 (if (calendar-date-is-visible-p date) | |
270 (list (list date string)))))))) | |
271 | |
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
272 (defun holiday-hebrew (month day string) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
273 "Holiday on MONTH, DAY (Hebrew) called STRING. |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
274 If MONTH, DAY (Hebrew) is visible, the value returned is corresponding |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
275 Gregorian date in the form of the list (((month day year) STRING)). Returns |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
276 nil if it is not visible in the current calendar window." |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
277 (if (memq displayed-month;; This test is only to speed things up a bit; |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
278 (list ;; it works fine without the test too. |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
279 (if (< 11 month) (- month 11) (+ month 1)) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
280 (if (< 10 month) (- month 10) (+ month 2)) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
281 (if (< 9 month) (- month 9) (+ month 3)) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
282 (if (< 8 month) (- month 8) (+ month 4)) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
283 (if (< 7 month) (- month 7) (+ month 5)))) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
284 (let ((m1 displayed-month) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
285 (y1 displayed-year) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
286 (m2 displayed-month) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
287 (y2 displayed-year) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
288 (year)) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
289 (increment-calendar-month m1 y1 -1) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
290 (increment-calendar-month m2 y2 1) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
291 (let* ((start-date (calendar-absolute-from-gregorian |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
292 (list m1 1 y1))) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
293 (end-date (calendar-absolute-from-gregorian |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
294 (list m2 (calendar-last-day-of-month m2 y2) y2))) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
295 (hebrew-start (calendar-hebrew-from-absolute start-date)) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
296 (hebrew-end (calendar-hebrew-from-absolute end-date)) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
297 (hebrew-y1 (extract-calendar-year hebrew-start)) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
298 (hebrew-y2 (extract-calendar-year hebrew-end))) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
299 (setq year (if (< 6 month) hebrew-y2 hebrew-y1)) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
300 (let ((date (calendar-gregorian-from-absolute |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
301 (calendar-absolute-from-hebrew |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
302 (list month day year))))) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
303 (if (calendar-date-is-visible-p date) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
304 (list (list date string)))))))) |
406 | 305 |
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
306 (defun holiday-sexp (sexp string) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
307 "Sexp holiday for dates in the calendar window. |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
308 SEXP is an expression in variable `year' evaluates to `date'. |
406 | 309 |
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
310 STRING is an expression in `date' that evaluates to the holiday description |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
311 of `date'. |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
312 |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
313 If `date' is visible in the calendar window, the holiday STRING is on that |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
314 date. If date is nil, or if the date is not visible, there is no holiday." |
957 | 315 (let ((m displayed-month) |
316 (y displayed-year)) | |
317 (increment-calendar-month m y -1) | |
318 (filter-visible-calendar-holidays | |
319 (append | |
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
320 (let* ((year y) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
321 (date (eval sexp)) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
322 (string (if date (eval string)))) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
323 (list (list date string))) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
324 (let* ((year (1+ y)) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
325 (date (eval sexp)) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
326 (string (if date (eval string)))) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
327 (list (list date string))))))) |
957 | 328 |
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
329 (defun holiday-advent () |
406 | 330 "Date of Advent, if visible in calendar window." |
331 (let ((year displayed-year) | |
332 (month displayed-month)) | |
333 (increment-calendar-month month year -1) | |
334 (let ((advent (calendar-gregorian-from-absolute | |
335 (calendar-dayname-on-or-before 0 | |
336 (calendar-absolute-from-gregorian | |
337 (list 12 3 year)))))) | |
338 (if (calendar-date-is-visible-p advent) | |
339 (list (list advent "Advent")))))) | |
340 | |
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
341 (defun holiday-easter-etc () |
406 | 342 "List of dates related to Easter, as visible in calendar window." |
343 (if (and (> displayed-month 5) (not all-christian-calendar-holidays)) | |
344 nil;; Ash Wednesday, Good Friday, and Easter are not visible. | |
345 (let* ((century (1+ (/ displayed-year 100))) | |
346 (shifted-epact ;; Age of moon for April 5... | |
347 (% (+ 14 (* 11 (% displayed-year 19));; ...by Nicaean rule | |
348 (- ;; ...corrected for the Gregorian century rule | |
349 (/ (* 3 century) 4)) | |
350 (/ ;; ...corrected for Metonic cycle inaccuracy. | |
351 (+ 5 (* 8 century)) 25) | |
352 (* 30 century));; Keeps value positive. | |
353 30)) | |
354 (adjusted-epact ;; Adjust for 29.5 day month. | |
355 (if (or (= shifted-epact 0) | |
356 (and (= shifted-epact 1) (< 10 (% displayed-year 19)))) | |
357 (1+ shifted-epact) | |
358 shifted-epact)) | |
359 (paschal-moon ;; Day after the full moon on or after March 21. | |
360 (- (calendar-absolute-from-gregorian (list 4 19 displayed-year)) | |
361 adjusted-epact)) | |
362 (abs-easter (calendar-dayname-on-or-before 0 (+ paschal-moon 7))) | |
363 (mandatory | |
364 (list | |
365 (list (calendar-gregorian-from-absolute abs-easter) | |
366 "Easter Sunday") | |
367 (list (calendar-gregorian-from-absolute (- abs-easter 2)) | |
368 "Good Friday") | |
369 (list (calendar-gregorian-from-absolute (- abs-easter 46)) | |
370 "Ash Wednesday"))) | |
371 (optional | |
372 (list | |
373 (list (calendar-gregorian-from-absolute (- abs-easter 63)) | |
374 "Septuagesima Sunday") | |
375 (list (calendar-gregorian-from-absolute (- abs-easter 56)) | |
376 "Sexagesima Sunday") | |
377 (list (calendar-gregorian-from-absolute (- abs-easter 49)) | |
378 "Shrove Sunday") | |
379 (list (calendar-gregorian-from-absolute (- abs-easter 48)) | |
380 "Shrove Monday") | |
381 (list (calendar-gregorian-from-absolute (- abs-easter 47)) | |
382 "Shrove Tuesday") | |
383 (list (calendar-gregorian-from-absolute (- abs-easter 14)) | |
384 "Passion Sunday") | |
385 (list (calendar-gregorian-from-absolute (- abs-easter 7)) | |
386 "Palm Sunday") | |
387 (list (calendar-gregorian-from-absolute (- abs-easter 3)) | |
388 "Maundy Thursday") | |
389 (list (calendar-gregorian-from-absolute (+ abs-easter 35)) | |
390 "Rogation Sunday") | |
391 (list (calendar-gregorian-from-absolute (+ abs-easter 39)) | |
4864
4bfa62882154
(holiday-easter-etc): Fix Ascension Day string.
Richard M. Stallman <rms@gnu.org>
parents:
3870
diff
changeset
|
392 "Ascension Day") |
406 | 393 (list (calendar-gregorian-from-absolute (+ abs-easter 49)) |
394 "Pentecost (Whitsunday)") | |
395 (list (calendar-gregorian-from-absolute (+ abs-easter 50)) | |
396 "Whitmunday") | |
397 (list (calendar-gregorian-from-absolute (+ abs-easter 56)) | |
398 "Trinity Sunday") | |
399 (list (calendar-gregorian-from-absolute (+ abs-easter 60)) | |
400 "Corpus Christi"))) | |
401 (output-list | |
402 (filter-visible-calendar-holidays mandatory))) | |
403 (if all-christian-calendar-holidays | |
404 (setq output-list | |
405 (append | |
406 (filter-visible-calendar-holidays optional) | |
407 output-list))) | |
408 output-list))) | |
409 | |
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
410 (defun holiday-greek-orthodox-easter () |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
411 "Date of Easter according to the rule of the Council of Nicaea." |
957 | 412 (let ((m displayed-month) |
413 (y displayed-year)) | |
414 (increment-calendar-month m y 1) | |
415 (let* ((julian-year | |
416 (extract-calendar-year | |
417 (calendar-julian-from-absolute | |
418 (calendar-absolute-from-gregorian | |
419 (list m (calendar-last-day-of-month m y) y))))) | |
420 (shifted-epact ;; Age of moon for April 5. | |
421 (% (+ 14 | |
422 (* 11 (% julian-year 19))) | |
423 30)) | |
424 (paschal-moon ;; Day after full moon on or after March 21. | |
425 (- (calendar-absolute-from-julian (list 4 19 julian-year)) | |
426 shifted-epact)) | |
427 (nicaean-easter;; Sunday following the Paschal moon | |
428 (calendar-gregorian-from-absolute | |
429 (calendar-dayname-on-or-before 0 (+ paschal-moon 7))))) | |
430 (if (calendar-date-is-visible-p nicaean-easter) | |
431 (list (list nicaean-easter "Pascha (Greek Orthodox Easter)")))))) | |
432 | |
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
433 (defun holiday-rosh-hashanah-etc () |
406 | 434 "List of dates related to Rosh Hashanah, as visible in calendar window." |
435 (if (or (< displayed-month 8) | |
436 (> displayed-month 11)) | |
437 nil;; None of the dates is visible | |
438 (let* ((abs-r-h (calendar-absolute-from-hebrew | |
439 (list 7 1 (+ displayed-year 3761)))) | |
440 (mandatory | |
441 (list | |
442 (list (calendar-gregorian-from-absolute abs-r-h) | |
443 (format "Rosh HaShanah %d" (+ 3761 displayed-year))) | |
444 (list (calendar-gregorian-from-absolute (+ abs-r-h 9)) | |
445 "Yom Kippur") | |
446 (list (calendar-gregorian-from-absolute (+ abs-r-h 14)) | |
447 "Sukkot") | |
448 (list (calendar-gregorian-from-absolute (+ abs-r-h 21)) | |
449 "Shemini Atzeret") | |
450 (list (calendar-gregorian-from-absolute (+ abs-r-h 22)) | |
451 "Simchat Torah"))) | |
452 (optional | |
453 (list | |
454 (list (calendar-gregorian-from-absolute | |
455 (calendar-dayname-on-or-before 6 (- abs-r-h 4))) | |
456 "Selichot (night)") | |
457 (list (calendar-gregorian-from-absolute (1- abs-r-h)) | |
458 "Erev Rosh HaShannah") | |
459 (list (calendar-gregorian-from-absolute (1+ abs-r-h)) | |
460 "Rosh HaShanah (second day)") | |
461 (list (calendar-gregorian-from-absolute | |
462 (if (= (% abs-r-h 7) 4) (+ abs-r-h 3) (+ abs-r-h 2))) | |
463 "Tzom Gedaliah") | |
464 (list (calendar-gregorian-from-absolute | |
465 (calendar-dayname-on-or-before 6 (+ 7 abs-r-h))) | |
466 "Shabbat Shuvah") | |
467 (list (calendar-gregorian-from-absolute (+ abs-r-h 8)) | |
468 "Erev Yom Kippur") | |
469 (list (calendar-gregorian-from-absolute (+ abs-r-h 13)) | |
470 "Erev Sukkot") | |
471 (list (calendar-gregorian-from-absolute (+ abs-r-h 15)) | |
472 "Sukkot (second day)") | |
473 (list (calendar-gregorian-from-absolute (+ abs-r-h 16)) | |
474 "Hol Hamoed Sukkot (first day)") | |
475 (list (calendar-gregorian-from-absolute (+ abs-r-h 17)) | |
476 "Hol Hamoed Sukkot (second day)") | |
477 (list (calendar-gregorian-from-absolute (+ abs-r-h 18)) | |
478 "Hol Hamoed Sukkot (third day)") | |
479 (list (calendar-gregorian-from-absolute (+ abs-r-h 19)) | |
480 "Hol Hamoed Sukkot (fourth day)") | |
481 (list (calendar-gregorian-from-absolute (+ abs-r-h 20)) | |
482 "Hoshannah Rabbah"))) | |
483 (output-list | |
484 (filter-visible-calendar-holidays mandatory))) | |
485 (if all-hebrew-calendar-holidays | |
486 (setq output-list | |
487 (append | |
488 (filter-visible-calendar-holidays optional) | |
489 output-list))) | |
490 output-list))) | |
491 | |
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
492 (defun holiday-hanukkah () |
406 | 493 "List of dates related to Hanukkah, as visible in calendar window." |
494 (if (memq displayed-month;; This test is only to speed things up a bit; | |
495 '(10 11 12 1 2));; it works fine without the test too. | |
496 (let ((m displayed-month) | |
497 (y displayed-year)) | |
498 (increment-calendar-month m y 1) | |
499 (let* ((h-y (extract-calendar-year | |
500 (calendar-hebrew-from-absolute | |
501 (calendar-absolute-from-gregorian | |
502 (list m (calendar-last-day-of-month m y) y))))) | |
503 (abs-h (calendar-absolute-from-hebrew (list 9 25 h-y)))) | |
504 (filter-visible-calendar-holidays | |
505 (list | |
506 (list (calendar-gregorian-from-absolute (1- abs-h)) | |
507 "Erev Hanukkah") | |
508 (list (calendar-gregorian-from-absolute abs-h) | |
509 "Hanukkah (first day)") | |
510 (list (calendar-gregorian-from-absolute (1+ abs-h)) | |
511 "Hanukkah (second day)") | |
512 (list (calendar-gregorian-from-absolute (+ abs-h 2)) | |
513 "Hanukkah (third day)") | |
514 (list (calendar-gregorian-from-absolute (+ abs-h 3)) | |
515 "Hanukkah (fourth day)") | |
516 (list (calendar-gregorian-from-absolute (+ abs-h 4)) | |
517 "Hanukkah (fifth day)") | |
518 (list (calendar-gregorian-from-absolute (+ abs-h 5)) | |
519 "Hanukkah (sixth day)") | |
520 (list (calendar-gregorian-from-absolute (+ abs-h 6)) | |
521 "Hanukkah (seventh day)") | |
522 (list (calendar-gregorian-from-absolute (+ abs-h 7)) | |
523 "Hanukkah (eighth day)"))))))) | |
524 | |
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
525 (defun holiday-passover-etc () |
406 | 526 "List of dates related to Passover, as visible in calendar window." |
527 (if (< 7 displayed-month) | |
528 nil;; None of the dates is visible | |
529 (let* ((abs-p (calendar-absolute-from-hebrew | |
530 (list 1 15 (+ displayed-year 3760)))) | |
531 (mandatory | |
532 (list | |
533 (list (calendar-gregorian-from-absolute abs-p) | |
534 "Passover") | |
535 (list (calendar-gregorian-from-absolute (+ abs-p 50)) | |
536 "Shavuot"))) | |
537 (optional | |
538 (list | |
539 (list (calendar-gregorian-from-absolute | |
540 (calendar-dayname-on-or-before 6 (- abs-p 43))) | |
541 "Shabbat Shekalim") | |
542 (list (calendar-gregorian-from-absolute | |
543 (calendar-dayname-on-or-before 6 (- abs-p 30))) | |
544 "Shabbat Zachor") | |
545 (list (calendar-gregorian-from-absolute | |
546 (if (= (% abs-p 7) 2) (- abs-p 33) (- abs-p 31))) | |
547 "Fast of Esther") | |
548 (list (calendar-gregorian-from-absolute (- abs-p 31)) | |
549 "Erev Purim") | |
550 (list (calendar-gregorian-from-absolute (- abs-p 30)) | |
551 "Purim") | |
552 (list (calendar-gregorian-from-absolute | |
553 (if (zerop (% abs-p 7)) (- abs-p 28) (- abs-p 29))) | |
554 "Shushan Purim") | |
555 (list (calendar-gregorian-from-absolute | |
556 (- (calendar-dayname-on-or-before 6 (- abs-p 14)) 7)) | |
557 "Shabbat Parah") | |
558 (list (calendar-gregorian-from-absolute | |
559 (calendar-dayname-on-or-before 6 (- abs-p 14))) | |
560 "Shabbat HaHodesh") | |
561 (list (calendar-gregorian-from-absolute | |
562 (calendar-dayname-on-or-before 6 (1- abs-p))) | |
563 "Shabbat HaGadol") | |
564 (list (calendar-gregorian-from-absolute (1- abs-p)) | |
565 "Erev Passover") | |
566 (list (calendar-gregorian-from-absolute (1+ abs-p)) | |
567 "Passover (second day)") | |
568 (list (calendar-gregorian-from-absolute (+ abs-p 2)) | |
569 "Hol Hamoed Passover (first day)") | |
570 (list (calendar-gregorian-from-absolute (+ abs-p 3)) | |
571 "Hol Hamoed Passover (second day)") | |
572 (list (calendar-gregorian-from-absolute (+ abs-p 4)) | |
573 "Hol Hamoed Passover (third day)") | |
574 (list (calendar-gregorian-from-absolute (+ abs-p 5)) | |
575 "Hol Hamoed Passover (fourth day)") | |
576 (list (calendar-gregorian-from-absolute (+ abs-p 6)) | |
577 "Passover (seventh day)") | |
578 (list (calendar-gregorian-from-absolute (+ abs-p 7)) | |
579 "Passover (eighth day)") | |
580 (list (calendar-gregorian-from-absolute (+ abs-p 12)) | |
581 "Yom HaShoah") | |
582 (list (calendar-gregorian-from-absolute | |
583 (if (zerop (% abs-p 7)) | |
584 (+ abs-p 18) | |
585 (if (= (% abs-p 7) 6) | |
586 (+ abs-p 19) | |
587 (+ abs-p 20)))) | |
588 "Yom HaAtzma'ut") | |
589 (list (calendar-gregorian-from-absolute (+ abs-p 33)) | |
590 "Lag BaOmer") | |
591 (list (calendar-gregorian-from-absolute (+ abs-p 43)) | |
592 "Yom Yerushalim") | |
593 (list (calendar-gregorian-from-absolute (+ abs-p 49)) | |
594 "Erev Shavuot") | |
595 (list (calendar-gregorian-from-absolute (+ abs-p 51)) | |
596 "Shavuot (second day)"))) | |
597 (output-list | |
598 (filter-visible-calendar-holidays mandatory))) | |
599 (if all-hebrew-calendar-holidays | |
600 (setq output-list | |
601 (append | |
602 (filter-visible-calendar-holidays optional) | |
603 output-list))) | |
604 output-list))) | |
605 | |
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
606 (defun holiday-tisha-b-av-etc () |
406 | 607 "List of dates around Tisha B'Av, as visible in calendar window." |
608 (if (or (< displayed-month 5) | |
609 (> displayed-month 9)) | |
610 nil;; None of the dates is visible | |
611 (let* ((abs-t-a (calendar-absolute-from-hebrew | |
612 (list 5 9 (+ displayed-year 3760))))) | |
613 | |
614 (filter-visible-calendar-holidays | |
615 (list | |
616 (list (calendar-gregorian-from-absolute | |
617 (if (= (% abs-t-a 7) 6) (- abs-t-a 20) (- abs-t-a 21))) | |
618 "Tzom Tammuz") | |
619 (list (calendar-gregorian-from-absolute | |
620 (calendar-dayname-on-or-before 6 abs-t-a)) | |
621 "Shabbat Hazon") | |
622 (list (calendar-gregorian-from-absolute | |
623 (if (= (% abs-t-a 7) 6) (1+ abs-t-a) abs-t-a)) | |
624 "Tisha B'Av") | |
625 (list (calendar-gregorian-from-absolute | |
626 (calendar-dayname-on-or-before 6 (+ abs-t-a 7))) | |
627 "Shabbat Nahamu")))))) | |
628 | |
629 (defun filter-visible-calendar-holidays (l) | |
630 "Return a list of all visible holidays of those on L." | |
631 (let ((visible) | |
632 (p l)) | |
633 (while p | |
2945
2c1f0215fcc3
* holidays.el: Update reference to the papers in S-P&E.
Jim Blandy <jimb@redhat.com>
parents:
957
diff
changeset
|
634 (and (car (car p)) |
2c1f0215fcc3
* holidays.el: Update reference to the papers in S-P&E.
Jim Blandy <jimb@redhat.com>
parents:
957
diff
changeset
|
635 (calendar-date-is-visible-p (car (car p))) |
2c1f0215fcc3
* holidays.el: Update reference to the papers in S-P&E.
Jim Blandy <jimb@redhat.com>
parents:
957
diff
changeset
|
636 (setq visible (append (list (car p)) visible))) |
406 | 637 (setq p (cdr p))) |
638 visible)) | |
584 | 639 |
640 (provide 'holidays) | |
641 | |
660
08eb386dd0f3
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
584
diff
changeset
|
642 ;;; holidays.el ends here |