]> code.delx.au - gnu-emacs/blob - lisp/calendar/cal-hebrew.el
(default-sendmail-coding-system): Doc fix.
[gnu-emacs] / lisp / calendar / cal-hebrew.el
1 ;;; cal-hebrew.el --- calendar functions for the Hebrew calendar
2
3 ;; Copyright (C) 1995, 1997, 2003 Free Software Foundation, Inc.
4
5 ;; Author: Nachum Dershowitz <nachum@cs.uiuc.edu>
6 ;; Edward M. Reingold <reingold@cs.uiuc.edu>
7 ;; Keywords: calendar
8 ;; Human-Keywords: Hebrew calendar, calendar, diary
9
10 ;; This file is part of GNU Emacs.
11
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; any later version.
16
17 ;; GNU Emacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
21
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
24 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
25 ;; Boston, MA 02110-1301, USA.
26
27 ;;; Commentary:
28
29 ;; This collection of functions implements the features of calendar.el and
30 ;; diary.el that deal with the Hebrew calendar.
31
32 ;; Technical details of all the calendrical calculations can be found in
33 ;; ``Calendrical Calculations: The Millennium Edition'' by Edward M. Reingold
34 ;; and Nachum Dershowitz, Cambridge University Press (2001).
35
36 ;; Comments, corrections, and improvements should be sent to
37 ;; Edward M. Reingold Department of Computer Science
38 ;; (217) 333-6733 University of Illinois at Urbana-Champaign
39 ;; reingold@cs.uiuc.edu 1304 West Springfield Avenue
40 ;; Urbana, Illinois 61801
41
42 ;;; Code:
43
44 (defvar date)
45 (defvar displayed-month)
46 (defvar displayed-year)
47 (defvar entry)
48 (defvar number)
49 (defvar original-date)
50
51 (require 'calendar)
52
53 (defun hebrew-calendar-leap-year-p (year)
54 "t if YEAR is a Hebrew calendar leap year."
55 (< (% (1+ (* 7 year)) 19) 7))
56
57 (defun hebrew-calendar-last-month-of-year (year)
58 "The last month of the Hebrew calendar YEAR."
59 (if (hebrew-calendar-leap-year-p year)
60 13
61 12))
62
63 (defun hebrew-calendar-elapsed-days (year)
64 "Days from Sun. prior to start of Hebrew calendar to mean conjunction of Tishri of Hebrew YEAR."
65 (let* ((months-elapsed
66 (+ (* 235 (/ (1- year) 19));; Months in complete cycles so far.
67 (* 12 (% (1- year) 19)) ;; Regular months in this cycle
68 (/ (1+ (* 7 (% (1- year) 19))) 19)));; Leap months this cycle
69 (parts-elapsed (+ 204 (* 793 (% months-elapsed 1080))))
70 (hours-elapsed (+ 5
71 (* 12 months-elapsed)
72 (* 793 (/ months-elapsed 1080))
73 (/ parts-elapsed 1080)))
74 (parts ;; Conjunction parts
75 (+ (* 1080 (% hours-elapsed 24)) (% parts-elapsed 1080)))
76 (day ;; Conjunction day
77 (+ 1 (* 29 months-elapsed) (/ hours-elapsed 24)))
78 (alternative-day
79 (if (or (>= parts 19440) ;; If the new moon is at or after midday,
80 (and (= (% day 7) 2);; ...or is on a Tuesday...
81 (>= parts 9924) ;; at 9 hours, 204 parts or later...
82 (not (hebrew-calendar-leap-year-p year)));; of a
83 ;; common year,
84 (and (= (% day 7) 1);; ...or is on a Monday...
85 (>= parts 16789) ;; at 15 hours, 589 parts or later...
86 (hebrew-calendar-leap-year-p (1- year))));; at the end
87 ;; of a leap year
88 ;; Then postpone Rosh HaShanah one day
89 (1+ day)
90 ;; Else
91 day)))
92 (if ;; If Rosh HaShanah would occur on Sunday, Wednesday, or Friday
93 (memq (% alternative-day 7) (list 0 3 5))
94 ;; Then postpone it one (more) day and return
95 (1+ alternative-day)
96 ;; Else return
97 alternative-day)))
98
99 (defun hebrew-calendar-days-in-year (year)
100 "Number of days in Hebrew YEAR."
101 (- (hebrew-calendar-elapsed-days (1+ year))
102 (hebrew-calendar-elapsed-days year)))
103
104 (defun hebrew-calendar-long-heshvan-p (year)
105 "t if Heshvan is long in Hebrew YEAR."
106 (= (% (hebrew-calendar-days-in-year year) 10) 5))
107
108 (defun hebrew-calendar-short-kislev-p (year)
109 "t if Kislev is short in Hebrew YEAR."
110 (= (% (hebrew-calendar-days-in-year year) 10) 3))
111
112 (defun hebrew-calendar-last-day-of-month (month year)
113 "The last day of MONTH in YEAR."
114 (if (or (memq month (list 2 4 6 10 13))
115 (and (= month 12) (not (hebrew-calendar-leap-year-p year)))
116 (and (= month 8) (not (hebrew-calendar-long-heshvan-p year)))
117 (and (= month 9) (hebrew-calendar-short-kislev-p year)))
118 29
119 30))
120
121 (defun calendar-absolute-from-hebrew (date)
122 "Absolute date of Hebrew DATE.
123 The absolute date is the number of days elapsed since the (imaginary)
124 Gregorian date Sunday, December 31, 1 BC."
125 (let* ((month (extract-calendar-month date))
126 (day (extract-calendar-day date))
127 (year (extract-calendar-year date)))
128 (+ day ;; Days so far this month.
129 (if (< month 7);; before Tishri
130 ;; Then add days in prior months this year before and after Nisan
131 (+ (calendar-sum
132 m 7 (<= m (hebrew-calendar-last-month-of-year year))
133 (hebrew-calendar-last-day-of-month m year))
134 (calendar-sum
135 m 1 (< m month)
136 (hebrew-calendar-last-day-of-month m year)))
137 ;; Else add days in prior months this year
138 (calendar-sum
139 m 7 (< m month)
140 (hebrew-calendar-last-day-of-month m year)))
141 (hebrew-calendar-elapsed-days year);; Days in prior years.
142 -1373429))) ;; Days elapsed before absolute date 1.
143
144 (defun calendar-hebrew-from-absolute (date)
145 "Compute the Hebrew date (month day year) corresponding to absolute DATE.
146 The absolute date is the number of days elapsed since the (imaginary)
147 Gregorian date Sunday, December 31, 1 BC."
148 (let* ((greg-date (calendar-gregorian-from-absolute date))
149 (month (aref [9 10 11 12 1 2 3 4 7 7 7 8]
150 (1- (extract-calendar-month greg-date))))
151 (day)
152 (year (+ 3760 (extract-calendar-year greg-date))))
153 (while (>= date (calendar-absolute-from-hebrew (list 7 1 (1+ year))))
154 (setq year (1+ year)))
155 (let ((length (hebrew-calendar-last-month-of-year year)))
156 (while (> date
157 (calendar-absolute-from-hebrew
158 (list month
159 (hebrew-calendar-last-day-of-month month year)
160 year)))
161 (setq month (1+ (% month length)))))
162 (setq day (1+
163 (- date (calendar-absolute-from-hebrew (list month 1 year)))))
164 (list month day year)))
165
166 (defvar calendar-hebrew-month-name-array-common-year
167 ["Nisan" "Iyar" "Sivan" "Tammuz" "Av" "Elul" "Tishri"
168 "Heshvan" "Kislev" "Teveth" "Shevat" "Adar"]
169 "Array of strings giving the names of the Hebrew months in a common year.")
170
171 (defvar calendar-hebrew-month-name-array-leap-year
172 ["Nisan" "Iyar" "Sivan" "Tammuz" "Av" "Elul" "Tishri"
173 "Heshvan" "Kislev" "Teveth" "Shevat" "Adar I" "Adar II"]
174 "Array of strings giving the names of the Hebrew months in a leap year.")
175
176 (defun calendar-hebrew-date-string (&optional date)
177 "String of Hebrew date before sunset of Gregorian DATE.
178 Defaults to today's date if DATE is not given.
179 Driven by the variable `calendar-date-display-form'."
180 (let* ((hebrew-date (calendar-hebrew-from-absolute
181 (calendar-absolute-from-gregorian
182 (or date (calendar-current-date)))))
183 (calendar-month-name-array
184 (if (hebrew-calendar-leap-year-p (extract-calendar-year hebrew-date))
185 calendar-hebrew-month-name-array-leap-year
186 calendar-hebrew-month-name-array-common-year)))
187 (calendar-date-string hebrew-date nil t)))
188
189 (defun calendar-print-hebrew-date ()
190 "Show the Hebrew calendar equivalent of the date under the cursor."
191 (interactive)
192 (message "Hebrew date (until sunset): %s"
193 (calendar-hebrew-date-string (calendar-cursor-to-date t))))
194
195 (defun hebrew-calendar-yahrzeit (death-date year)
196 "Absolute date of the anniversary of Hebrew DEATH-DATE in Hebrew YEAR."
197 (let* ((death-day (extract-calendar-day death-date))
198 (death-month (extract-calendar-month death-date))
199 (death-year (extract-calendar-year death-date)))
200 (cond
201 ;; If it's Heshvan 30 it depends on the first anniversary; if
202 ;; that was not Heshvan 30, use the day before Kislev 1.
203 ((and (= death-month 8)
204 (= death-day 30)
205 (not (hebrew-calendar-long-heshvan-p (1+ death-year))))
206 (1- (calendar-absolute-from-hebrew (list 9 1 year))))
207 ;; If it's Kislev 30 it depends on the first anniversary; if
208 ;; that was not Kislev 30, use the day before Teveth 1.
209 ((and (= death-month 9)
210 (= death-day 30)
211 (hebrew-calendar-short-kislev-p (1+ death-year)))
212 (1- (calendar-absolute-from-hebrew (list 10 1 year))))
213 ;; If it's Adar II, use the same day in last month of
214 ;; year (Adar or Adar II).
215 ((= death-month 13)
216 (calendar-absolute-from-hebrew
217 (list (hebrew-calendar-last-month-of-year year) death-day year)))
218 ;; If it's the 30th in Adar I and year is not a leap year
219 ;; (so Adar has only 29 days), use the last day in Shevat.
220 ((and (= death-day 30)
221 (= death-month 12)
222 (not (hebrew-calendar-leap-year-p year)))
223 (calendar-absolute-from-hebrew (list 11 30 year)))
224 ;; In all other cases, use the normal anniversary of the date of death.
225 (t (calendar-absolute-from-hebrew
226 (list death-month death-day year))))))
227
228 (defun calendar-goto-hebrew-date (date &optional noecho)
229 "Move cursor to Hebrew DATE; echo Hebrew date unless NOECHO is t."
230 (interactive
231 (let* ((today (calendar-current-date))
232 (year (calendar-read
233 "Hebrew calendar year (>3760): "
234 '(lambda (x) (> x 3760))
235 (int-to-string
236 (extract-calendar-year
237 (calendar-hebrew-from-absolute
238 (calendar-absolute-from-gregorian today))))))
239 (month-array (if (hebrew-calendar-leap-year-p year)
240 calendar-hebrew-month-name-array-leap-year
241 calendar-hebrew-month-name-array-common-year))
242 (completion-ignore-case t)
243 (month (cdr (assoc-string
244 (completing-read
245 "Hebrew calendar month name: "
246 (mapcar 'list (append month-array nil))
247 (if (= year 3761)
248 '(lambda (x)
249 (let ((m (cdr
250 (assoc-string
251 (car x)
252 (calendar-make-alist month-array)
253 t))))
254 (< 0
255 (calendar-absolute-from-hebrew
256 (list m
257 (hebrew-calendar-last-day-of-month
258 m year)
259 year))))))
260 t)
261 (calendar-make-alist month-array 1) t)))
262 (last (hebrew-calendar-last-day-of-month month year))
263 (first (if (and (= year 3761) (= month 10))
264 18 1))
265 (day (calendar-read
266 (format "Hebrew calendar day (%d-%d): "
267 first last)
268 '(lambda (x) (and (<= first x) (<= x last))))))
269 (list (list month day year))))
270 (calendar-goto-date (calendar-gregorian-from-absolute
271 (calendar-absolute-from-hebrew date)))
272 (or noecho (calendar-print-hebrew-date)))
273
274 (defun holiday-hebrew (month day string)
275 "Holiday on MONTH, DAY (Hebrew) called STRING.
276 If MONTH, DAY (Hebrew) is visible, the value returned is corresponding
277 Gregorian date in the form of the list (((month day year) STRING)). Returns
278 nil if it is not visible in the current calendar window."
279 (if (memq displayed-month;; This test is only to speed things up a bit;
280 (list ;; it works fine without the test too.
281 (if (< 11 month) (- month 11) (+ month 1))
282 (if (< 10 month) (- month 10) (+ month 2))
283 (if (< 9 month) (- month 9) (+ month 3))
284 (if (< 8 month) (- month 8) (+ month 4))
285 (if (< 7 month) (- month 7) (+ month 5))))
286 (let ((m1 displayed-month)
287 (y1 displayed-year)
288 (m2 displayed-month)
289 (y2 displayed-year)
290 (year))
291 (increment-calendar-month m1 y1 -1)
292 (increment-calendar-month m2 y2 1)
293 (let* ((start-date (calendar-absolute-from-gregorian
294 (list m1 1 y1)))
295 (end-date (calendar-absolute-from-gregorian
296 (list m2 (calendar-last-day-of-month m2 y2) y2)))
297 (hebrew-start (calendar-hebrew-from-absolute start-date))
298 (hebrew-end (calendar-hebrew-from-absolute end-date))
299 (hebrew-y1 (extract-calendar-year hebrew-start))
300 (hebrew-y2 (extract-calendar-year hebrew-end)))
301 (setq year (if (< 6 month) hebrew-y2 hebrew-y1))
302 (let ((date (calendar-gregorian-from-absolute
303 (calendar-absolute-from-hebrew
304 (list month day year)))))
305 (if (calendar-date-is-visible-p date)
306 (list (list date string))))))))
307
308 (defun holiday-rosh-hashanah-etc ()
309 "List of dates related to Rosh Hashanah, as visible in calendar window."
310 (if (or (< displayed-month 8)
311 (> displayed-month 11))
312 nil;; None of the dates is visible
313 (let* ((abs-r-h (calendar-absolute-from-hebrew
314 (list 7 1 (+ displayed-year 3761))))
315 (mandatory
316 (list
317 (list (calendar-gregorian-from-absolute abs-r-h)
318 (format "Rosh HaShanah %d" (+ 3761 displayed-year)))
319 (list (calendar-gregorian-from-absolute (+ abs-r-h 9))
320 "Yom Kippur")
321 (list (calendar-gregorian-from-absolute (+ abs-r-h 14))
322 "Sukkot")
323 (list (calendar-gregorian-from-absolute (+ abs-r-h 21))
324 "Shemini Atzeret")
325 (list (calendar-gregorian-from-absolute (+ abs-r-h 22))
326 "Simchat Torah")))
327 (optional
328 (list
329 (list (calendar-gregorian-from-absolute
330 (calendar-dayname-on-or-before 6 (- abs-r-h 4)))
331 "Selichot (night)")
332 (list (calendar-gregorian-from-absolute (1- abs-r-h))
333 "Erev Rosh HaShanah")
334 (list (calendar-gregorian-from-absolute (1+ abs-r-h))
335 "Rosh HaShanah (second day)")
336 (list (calendar-gregorian-from-absolute
337 (if (= (% abs-r-h 7) 4) (+ abs-r-h 3) (+ abs-r-h 2)))
338 "Tzom Gedaliah")
339 (list (calendar-gregorian-from-absolute
340 (calendar-dayname-on-or-before 6 (+ 7 abs-r-h)))
341 "Shabbat Shuvah")
342 (list (calendar-gregorian-from-absolute (+ abs-r-h 8))
343 "Erev Yom Kippur")
344 (list (calendar-gregorian-from-absolute (+ abs-r-h 13))
345 "Erev Sukkot")
346 (list (calendar-gregorian-from-absolute (+ abs-r-h 15))
347 "Sukkot (second day)")
348 (list (calendar-gregorian-from-absolute (+ abs-r-h 16))
349 "Hol Hamoed Sukkot (first day)")
350 (list (calendar-gregorian-from-absolute (+ abs-r-h 17))
351 "Hol Hamoed Sukkot (second day)")
352 (list (calendar-gregorian-from-absolute (+ abs-r-h 18))
353 "Hol Hamoed Sukkot (third day)")
354 (list (calendar-gregorian-from-absolute (+ abs-r-h 19))
355 "Hol Hamoed Sukkot (fourth day)")
356 (list (calendar-gregorian-from-absolute (+ abs-r-h 20))
357 "Hoshanah Rabbah")))
358 (output-list
359 (filter-visible-calendar-holidays mandatory)))
360 (if all-hebrew-calendar-holidays
361 (setq output-list
362 (append
363 (filter-visible-calendar-holidays optional)
364 output-list)))
365 output-list)))
366
367 (defun holiday-hanukkah ()
368 "List of dates related to Hanukkah, as visible in calendar window."
369 (if (memq displayed-month;; This test is only to speed things up a bit;
370 '(10 11 12 1 2));; it works fine without the test too.
371 (let ((m displayed-month)
372 (y displayed-year))
373 (increment-calendar-month m y 1)
374 (let* ((h-y (extract-calendar-year
375 (calendar-hebrew-from-absolute
376 (calendar-absolute-from-gregorian
377 (list m (calendar-last-day-of-month m y) y)))))
378 (abs-h (calendar-absolute-from-hebrew (list 9 25 h-y))))
379 (filter-visible-calendar-holidays
380 (list
381 (list (calendar-gregorian-from-absolute (1- abs-h))
382 "Erev Hanukkah")
383 (list (calendar-gregorian-from-absolute abs-h)
384 "Hanukkah (first day)")
385 (list (calendar-gregorian-from-absolute (1+ abs-h))
386 "Hanukkah (second day)")
387 (list (calendar-gregorian-from-absolute (+ abs-h 2))
388 "Hanukkah (third day)")
389 (list (calendar-gregorian-from-absolute (+ abs-h 3))
390 "Hanukkah (fourth day)")
391 (list (calendar-gregorian-from-absolute (+ abs-h 4))
392 "Hanukkah (fifth day)")
393 (list (calendar-gregorian-from-absolute (+ abs-h 5))
394 "Hanukkah (sixth day)")
395 (list (calendar-gregorian-from-absolute (+ abs-h 6))
396 "Hanukkah (seventh day)")
397 (list (calendar-gregorian-from-absolute (+ abs-h 7))
398 "Hanukkah (eighth day)")))))))
399
400 (defun holiday-passover-etc ()
401 "List of dates related to Passover, as visible in calendar window."
402 (if (< 7 displayed-month)
403 nil;; None of the dates is visible
404 (let* ((abs-p (calendar-absolute-from-hebrew
405 (list 1 15 (+ displayed-year 3760))))
406 (mandatory
407 (list
408 (list (calendar-gregorian-from-absolute abs-p)
409 "Passover")
410 (list (calendar-gregorian-from-absolute (+ abs-p 50))
411 "Shavuot")))
412 (optional
413 (list
414 (list (calendar-gregorian-from-absolute
415 (calendar-dayname-on-or-before 6 (- abs-p 43)))
416 "Shabbat Shekalim")
417 (list (calendar-gregorian-from-absolute
418 (calendar-dayname-on-or-before 6 (- abs-p 30)))
419 "Shabbat Zachor")
420 (list (calendar-gregorian-from-absolute
421 (if (= (% abs-p 7) 2) (- abs-p 33) (- abs-p 31)))
422 "Fast of Esther")
423 (list (calendar-gregorian-from-absolute (- abs-p 31))
424 "Erev Purim")
425 (list (calendar-gregorian-from-absolute (- abs-p 30))
426 "Purim")
427 (list (calendar-gregorian-from-absolute
428 (if (zerop (% abs-p 7)) (- abs-p 28) (- abs-p 29)))
429 "Shushan Purim")
430 (list (calendar-gregorian-from-absolute
431 (- (calendar-dayname-on-or-before 6 (- abs-p 14)) 7))
432 "Shabbat Parah")
433 (list (calendar-gregorian-from-absolute
434 (calendar-dayname-on-or-before 6 (- abs-p 14)))
435 "Shabbat HaHodesh")
436 (list (calendar-gregorian-from-absolute
437 (calendar-dayname-on-or-before 6 (1- abs-p)))
438 "Shabbat HaGadol")
439 (list (calendar-gregorian-from-absolute (1- abs-p))
440 "Erev Passover")
441 (list (calendar-gregorian-from-absolute (1+ abs-p))
442 "Passover (second day)")
443 (list (calendar-gregorian-from-absolute (+ abs-p 2))
444 "Hol Hamoed Passover (first day)")
445 (list (calendar-gregorian-from-absolute (+ abs-p 3))
446 "Hol Hamoed Passover (second day)")
447 (list (calendar-gregorian-from-absolute (+ abs-p 4))
448 "Hol Hamoed Passover (third day)")
449 (list (calendar-gregorian-from-absolute (+ abs-p 5))
450 "Hol Hamoed Passover (fourth day)")
451 (list (calendar-gregorian-from-absolute (+ abs-p 6))
452 "Passover (seventh day)")
453 (list (calendar-gregorian-from-absolute (+ abs-p 7))
454 "Passover (eighth day)")
455 (list (calendar-gregorian-from-absolute
456 (if (zerop (% (+ abs-p 12) 7))
457 (+ abs-p 13)
458 (+ abs-p 12)))
459 "Yom HaShoah")
460 (list (calendar-gregorian-from-absolute
461 (if (zerop (% abs-p 7))
462 (+ abs-p 18)
463 (if (= (% abs-p 7) 6)
464 (+ abs-p 19)
465 (+ abs-p 20))))
466 "Yom HaAtzma'ut")
467 (list (calendar-gregorian-from-absolute (+ abs-p 33))
468 "Lag BaOmer")
469 (list (calendar-gregorian-from-absolute (+ abs-p 43))
470 "Yom Yerushalaim")
471 (list (calendar-gregorian-from-absolute (+ abs-p 49))
472 "Erev Shavuot")
473 (list (calendar-gregorian-from-absolute (+ abs-p 51))
474 "Shavuot (second day)")))
475 (output-list
476 (filter-visible-calendar-holidays mandatory)))
477 (if all-hebrew-calendar-holidays
478 (setq output-list
479 (append
480 (filter-visible-calendar-holidays optional)
481 output-list)))
482 output-list)))
483
484 (defun holiday-tisha-b-av-etc ()
485 "List of dates around Tisha B'Av, as visible in calendar window."
486 (if (or (< displayed-month 5)
487 (> displayed-month 9))
488 nil;; None of the dates is visible
489 (let* ((abs-t-a (calendar-absolute-from-hebrew
490 (list 5 9 (+ displayed-year 3760)))))
491
492 (filter-visible-calendar-holidays
493 (list
494 (list (calendar-gregorian-from-absolute
495 (if (= (% abs-t-a 7) 6) (- abs-t-a 20) (- abs-t-a 21)))
496 "Tzom Tammuz")
497 (list (calendar-gregorian-from-absolute
498 (calendar-dayname-on-or-before 6 abs-t-a))
499 "Shabbat Hazon")
500 (list (calendar-gregorian-from-absolute
501 (if (= (% abs-t-a 7) 6) (1+ abs-t-a) abs-t-a))
502 "Tisha B'Av")
503 (list (calendar-gregorian-from-absolute
504 (calendar-dayname-on-or-before 6 (+ abs-t-a 7)))
505 "Shabbat Nahamu"))))))
506
507 (defun list-hebrew-diary-entries ()
508 "Add any Hebrew date entries from the diary file to `diary-entries-list'.
509 Hebrew date diary entries must be prefaced by `hebrew-diary-entry-symbol'
510 \(normally an `H'). The same diary date forms govern the style of the Hebrew
511 calendar entries, except that the Hebrew month names must be spelled in full.
512 The Hebrew months are numbered from 1 to 13 with Nisan being 1, 12 being
513 Adar I and 13 being Adar II; you must use `Adar I' if you want Adar of a
514 common Hebrew year. If a Hebrew date diary entry begins with a
515 `diary-nonmarking-symbol', the entry will appear in the diary listing, but will
516 not be marked in the calendar. This function is provided for use with the
517 `nongregorian-diary-listing-hook'."
518 (if (< 0 number)
519 (let ((buffer-read-only nil)
520 (diary-modified (buffer-modified-p))
521 (gdate original-date)
522 (mark (regexp-quote diary-nonmarking-symbol)))
523 (calendar-for-loop i from 1 to number do
524 (let* ((d diary-date-forms)
525 (hdate (calendar-hebrew-from-absolute
526 (calendar-absolute-from-gregorian gdate)))
527 (month (extract-calendar-month hdate))
528 (day (extract-calendar-day hdate))
529 (year (extract-calendar-year hdate)))
530 (while d
531 (let*
532 ((date-form (if (equal (car (car d)) 'backup)
533 (cdr (car d))
534 (car d)))
535 (backup (equal (car (car d)) 'backup))
536 (dayname
537 (format "%s\\|%s\\.?"
538 (calendar-day-name gdate)
539 (calendar-day-name gdate 'abbrev)))
540 (calendar-month-name-array
541 calendar-hebrew-month-name-array-leap-year)
542 (monthname
543 (concat
544 "\\*\\|"
545 (calendar-month-name month)))
546 (month (concat "\\*\\|0*" (int-to-string month)))
547 (day (concat "\\*\\|0*" (int-to-string day)))
548 (year
549 (concat
550 "\\*\\|0*" (int-to-string year)
551 (if abbreviated-calendar-year
552 (concat "\\|" (int-to-string (% year 100)))
553 "")))
554 (regexp
555 (concat
556 "\\(\\`\\|\^M\\|\n\\)" mark "?"
557 (regexp-quote hebrew-diary-entry-symbol)
558 "\\("
559 (mapconcat 'eval date-form "\\)\\(")
560 "\\)"))
561 (case-fold-search t))
562 (goto-char (point-min))
563 (while (re-search-forward regexp nil t)
564 (if backup (re-search-backward "\\<" nil t))
565 (if (and (or (char-equal (preceding-char) ?\^M)
566 (char-equal (preceding-char) ?\n))
567 (not (looking-at " \\|\^I")))
568 ;; Diary entry that consists only of date.
569 (backward-char 1)
570 ;; Found a nonempty diary entry--make it visible and
571 ;; add it to the list.
572 (let ((entry-start (point))
573 (date-start))
574 (re-search-backward "\^M\\|\n\\|\\`")
575 (setq date-start (point))
576 (re-search-forward "\^M\\|\n" nil t 2)
577 (while (looking-at " \\|\^I")
578 (re-search-forward "\^M\\|\n" nil t))
579 (backward-char 1)
580 (subst-char-in-region date-start (point) ?\^M ?\n t)
581 (add-to-diary-list
582 gdate
583 (buffer-substring-no-properties entry-start (point))
584 (buffer-substring-no-properties
585 (1+ date-start) (1- entry-start))
586 (copy-marker entry-start))))))
587 (setq d (cdr d))))
588 (setq gdate
589 (calendar-gregorian-from-absolute
590 (1+ (calendar-absolute-from-gregorian gdate)))))
591 (set-buffer-modified-p diary-modified))
592 (goto-char (point-min))))
593
594 (defun mark-hebrew-calendar-date-pattern (month day year)
595 "Mark dates in calendar window that conform to Hebrew date MONTH/DAY/YEAR.
596 A value of 0 in any position is a wildcard."
597 (save-excursion
598 (set-buffer calendar-buffer)
599 (if (and (/= 0 month) (/= 0 day))
600 (if (/= 0 year)
601 ;; Fully specified Hebrew date.
602 (let ((date (calendar-gregorian-from-absolute
603 (calendar-absolute-from-hebrew
604 (list month day year)))))
605 (if (calendar-date-is-visible-p date)
606 (mark-visible-calendar-date date)))
607 ;; Month and day in any year--this taken from the holiday stuff.
608 (if (memq displayed-month;; This test is only to speed things up a
609 (list ;; bit; it works fine without the test too.
610 (if (< 11 month) (- month 11) (+ month 1))
611 (if (< 10 month) (- month 10) (+ month 2))
612 (if (< 9 month) (- month 9) (+ month 3))
613 (if (< 8 month) (- month 8) (+ month 4))
614 (if (< 7 month) (- month 7) (+ month 5))))
615 (let ((m1 displayed-month)
616 (y1 displayed-year)
617 (m2 displayed-month)
618 (y2 displayed-year)
619 (year))
620 (increment-calendar-month m1 y1 -1)
621 (increment-calendar-month m2 y2 1)
622 (let* ((start-date (calendar-absolute-from-gregorian
623 (list m1 1 y1)))
624 (end-date (calendar-absolute-from-gregorian
625 (list m2
626 (calendar-last-day-of-month m2 y2)
627 y2)))
628 (hebrew-start
629 (calendar-hebrew-from-absolute start-date))
630 (hebrew-end (calendar-hebrew-from-absolute end-date))
631 (hebrew-y1 (extract-calendar-year hebrew-start))
632 (hebrew-y2 (extract-calendar-year hebrew-end)))
633 (setq year (if (< 6 month) hebrew-y2 hebrew-y1))
634 (let ((date (calendar-gregorian-from-absolute
635 (calendar-absolute-from-hebrew
636 (list month day year)))))
637 (if (calendar-date-is-visible-p date)
638 (mark-visible-calendar-date date)))))))
639 ;; Not one of the simple cases--check all visible dates for match.
640 ;; Actually, the following code takes care of ALL of the cases, but
641 ;; it's much too slow to be used for the simple (common) cases.
642 (let ((m displayed-month)
643 (y displayed-year)
644 (first-date)
645 (last-date))
646 (increment-calendar-month m y -1)
647 (setq first-date
648 (calendar-absolute-from-gregorian
649 (list m 1 y)))
650 (increment-calendar-month m y 2)
651 (setq last-date
652 (calendar-absolute-from-gregorian
653 (list m (calendar-last-day-of-month m y) y)))
654 (calendar-for-loop date from first-date to last-date do
655 (let* ((h-date (calendar-hebrew-from-absolute date))
656 (h-month (extract-calendar-month h-date))
657 (h-day (extract-calendar-day h-date))
658 (h-year (extract-calendar-year h-date)))
659 (and (or (zerop month)
660 (= month h-month))
661 (or (zerop day)
662 (= day h-day))
663 (or (zerop year)
664 (= year h-year))
665 (mark-visible-calendar-date
666 (calendar-gregorian-from-absolute date)))))))))
667
668 (defun mark-hebrew-diary-entries ()
669 "Mark days in the calendar window that have Hebrew date diary entries.
670 Each entry in diary-file (or included files) visible in the calendar window
671 is marked. Hebrew date entries are prefaced by a hebrew-diary-entry-symbol
672 \(normally an `H'). The same diary-date-forms govern the style of the Hebrew
673 calendar entries, except that the Hebrew month names must be spelled in full.
674 The Hebrew months are numbered from 1 to 13 with Nisan being 1, 12 being
675 Adar I and 13 being Adar II; you must use `Adar I' if you want Adar of a
676 common Hebrew year. Hebrew date diary entries that begin with a
677 diary-nonmarking symbol will not be marked in the calendar. This function
678 is provided for use as part of the nongregorian-diary-marking-hook."
679 (let ((d diary-date-forms))
680 (while d
681 (let*
682 ((date-form (if (equal (car (car d)) 'backup)
683 (cdr (car d))
684 (car d)));; ignore 'backup directive
685 (dayname (diary-name-pattern calendar-day-name-array
686 calendar-day-abbrev-array))
687 (monthname
688 (format "%s\\|\\*"
689 (diary-name-pattern
690 calendar-hebrew-month-name-array-leap-year)))
691 (month "[0-9]+\\|\\*")
692 (day "[0-9]+\\|\\*")
693 (year "[0-9]+\\|\\*")
694 (l (length date-form))
695 (d-name-pos (- l (length (memq 'dayname date-form))))
696 (d-name-pos (if (/= l d-name-pos) (+ 2 d-name-pos)))
697 (m-name-pos (- l (length (memq 'monthname date-form))))
698 (m-name-pos (if (/= l m-name-pos) (+ 2 m-name-pos)))
699 (d-pos (- l (length (memq 'day date-form))))
700 (d-pos (if (/= l d-pos) (+ 2 d-pos)))
701 (m-pos (- l (length (memq 'month date-form))))
702 (m-pos (if (/= l m-pos) (+ 2 m-pos)))
703 (y-pos (- l (length (memq 'year date-form))))
704 (y-pos (if (/= l y-pos) (+ 2 y-pos)))
705 (regexp
706 (concat
707 "\\(\\`\\|\^M\\|\n\\)"
708 (regexp-quote hebrew-diary-entry-symbol)
709 "\\("
710 (mapconcat 'eval date-form "\\)\\(")
711 "\\)"))
712 (case-fold-search t))
713 (goto-char (point-min))
714 (while (re-search-forward regexp nil t)
715 (let* ((dd-name
716 (if d-name-pos
717 (buffer-substring
718 (match-beginning d-name-pos)
719 (match-end d-name-pos))))
720 (mm-name
721 (if m-name-pos
722 (buffer-substring
723 (match-beginning m-name-pos)
724 (match-end m-name-pos))))
725 (mm (string-to-number
726 (if m-pos
727 (buffer-substring
728 (match-beginning m-pos)
729 (match-end m-pos))
730 "")))
731 (dd (string-to-number
732 (if d-pos
733 (buffer-substring
734 (match-beginning d-pos)
735 (match-end d-pos))
736 "")))
737 (y-str (if y-pos
738 (buffer-substring
739 (match-beginning y-pos)
740 (match-end y-pos))))
741 (yy (if (not y-str)
742 0
743 (if (and (= (length y-str) 2)
744 abbreviated-calendar-year)
745 (let* ((current-y
746 (extract-calendar-year
747 (calendar-hebrew-from-absolute
748 (calendar-absolute-from-gregorian
749 (calendar-current-date)))))
750 (y (+ (string-to-number y-str)
751 (* 100 (/ current-y 100)))))
752 (if (> (- y current-y) 50)
753 (- y 100)
754 (if (> (- current-y y) 50)
755 (+ y 100)
756 y)))
757 (string-to-number y-str)))))
758 (if dd-name
759 (mark-calendar-days-named
760 (cdr (assoc-string dd-name
761 (calendar-make-alist
762 calendar-day-name-array
763 0 nil calendar-day-abbrev-array) t)))
764 (if mm-name
765 (setq mm
766 (if (string-equal mm-name "*") 0
767 (cdr
768 (assoc-string
769 mm-name
770 (calendar-make-alist
771 calendar-hebrew-month-name-array-leap-year) t)))))
772 (mark-hebrew-calendar-date-pattern mm dd yy)))))
773 (setq d (cdr d)))))
774
775 (defun insert-hebrew-diary-entry (arg)
776 "Insert a diary entry.
777 For the Hebrew date corresponding to the date indicated by point.
778 Prefix arg will make the entry nonmarking."
779 (interactive "P")
780 (let* ((calendar-month-name-array
781 calendar-hebrew-month-name-array-leap-year))
782 (make-diary-entry
783 (concat
784 hebrew-diary-entry-symbol
785 (calendar-date-string
786 (calendar-hebrew-from-absolute
787 (calendar-absolute-from-gregorian
788 (calendar-cursor-to-date t)))
789 nil t))
790 arg)))
791
792 (defun insert-monthly-hebrew-diary-entry (arg)
793 "Insert a monthly diary entry.
794 For the day of the Hebrew month corresponding to the date indicated by point.
795 Prefix arg will make the entry nonmarking."
796 (interactive "P")
797 (let* ((calendar-date-display-form
798 (if european-calendar-style '(day " * ") '("* " day )))
799 (calendar-month-name-array
800 calendar-hebrew-month-name-array-leap-year))
801 (make-diary-entry
802 (concat
803 hebrew-diary-entry-symbol
804 (calendar-date-string
805 (calendar-hebrew-from-absolute
806 (calendar-absolute-from-gregorian
807 (calendar-cursor-to-date t)))))
808 arg)))
809
810 (defun insert-yearly-hebrew-diary-entry (arg)
811 "Insert an annual diary entry.
812 For the day of the Hebrew year corresponding to the date indicated by point.
813 Prefix arg will make the entry nonmarking."
814 (interactive "P")
815 (let* ((calendar-date-display-form
816 (if european-calendar-style
817 '(day " " monthname)
818 '(monthname " " day)))
819 (calendar-month-name-array
820 calendar-hebrew-month-name-array-leap-year))
821 (make-diary-entry
822 (concat
823 hebrew-diary-entry-symbol
824 (calendar-date-string
825 (calendar-hebrew-from-absolute
826 (calendar-absolute-from-gregorian
827 (calendar-cursor-to-date t)))))
828 arg)))
829
830 ;;;###autoload
831 (defun list-yahrzeit-dates (death-date start-year end-year)
832 "List Yahrzeit dates for *Gregorian* DEATH-DATE from START-YEAR to END-YEAR.
833 When called interactively from the calendar window, the date of death is taken
834 from the cursor position."
835 (interactive
836 (let* ((death-date
837 (if (equal (current-buffer) (get-buffer calendar-buffer))
838 (calendar-cursor-to-date)
839 (let* ((today (calendar-current-date))
840 (year (calendar-read
841 "Year of death (>0): "
842 '(lambda (x) (> x 0))
843 (int-to-string (extract-calendar-year today))))
844 (month-array calendar-month-name-array)
845 (completion-ignore-case t)
846 (month (cdr (assoc-string
847 (completing-read
848 "Month of death (name): "
849 (mapcar 'list (append month-array nil))
850 nil t)
851 (calendar-make-alist month-array 1) t)))
852 (last (calendar-last-day-of-month month year))
853 (day (calendar-read
854 (format "Day of death (1-%d): " last)
855 '(lambda (x) (and (< 0 x) (<= x last))))))
856 (list month day year))))
857 (death-year (extract-calendar-year death-date))
858 (start-year (calendar-read
859 (format "Starting year of Yahrzeit table (>%d): "
860 death-year)
861 '(lambda (x) (> x death-year))
862 (int-to-string (1+ death-year))))
863 (end-year (calendar-read
864 (format "Ending year of Yahrzeit table (>=%d): "
865 start-year)
866 '(lambda (x) (>= x start-year)))))
867 (list death-date start-year end-year)))
868 (message "Computing yahrzeits...")
869 (let* ((yahrzeit-buffer "*Yahrzeits*")
870 (h-date (calendar-hebrew-from-absolute
871 (calendar-absolute-from-gregorian death-date)))
872 (h-month (extract-calendar-month h-date))
873 (h-day (extract-calendar-day h-date))
874 (h-year (extract-calendar-year h-date)))
875 (set-buffer (get-buffer-create yahrzeit-buffer))
876 (setq buffer-read-only nil)
877 (calendar-set-mode-line
878 (format "Yahrzeit dates for %s = %s"
879 (calendar-date-string death-date)
880 (let ((calendar-month-name-array
881 (if (hebrew-calendar-leap-year-p h-year)
882 calendar-hebrew-month-name-array-leap-year
883 calendar-hebrew-month-name-array-common-year)))
884 (calendar-date-string h-date nil t))))
885 (erase-buffer)
886 (goto-char (point-min))
887 (calendar-for-loop i from start-year to end-year do
888 (insert
889 (calendar-date-string
890 (calendar-gregorian-from-absolute
891 (hebrew-calendar-yahrzeit
892 h-date
893 (extract-calendar-year
894 (calendar-hebrew-from-absolute
895 (calendar-absolute-from-gregorian (list 1 1 i))))))) "\n"))
896 (goto-char (point-min))
897 (set-buffer-modified-p nil)
898 (setq buffer-read-only t)
899 (display-buffer yahrzeit-buffer)
900 (message "Computing yahrzeits...done")))
901
902 (defun diary-hebrew-date ()
903 "Hebrew calendar equivalent of date diary entry."
904 (format "Hebrew date (until sunset): %s" (calendar-hebrew-date-string date)))
905
906 (defun diary-omer (&optional mark)
907 "Omer count diary entry.
908 Entry applies if date is within 50 days after Passover.
909
910 An optional parameter MARK specifies a face or single-character string to
911 use when highlighting the day in the calendar."
912 (let* ((passover
913 (calendar-absolute-from-hebrew
914 (list 1 15 (+ (extract-calendar-year date) 3760))))
915 (omer (- (calendar-absolute-from-gregorian date) passover))
916 (week (/ omer 7))
917 (day (% omer 7)))
918 (if (and (> omer 0) (< omer 50))
919 (cons mark
920 (format "Day %d%s of the omer (until sunset)"
921 omer
922 (if (zerop week)
923 ""
924 (format ", that is, %d week%s%s"
925 week
926 (if (= week 1) "" "s")
927 (if (zerop day)
928 ""
929 (format " and %d day%s"
930 day (if (= day 1) "" "s"))))))))))
931
932 (defun diary-yahrzeit (death-month death-day death-year &optional mark)
933 "Yahrzeit diary entry--entry applies if date is yahrzeit or the day before.
934 Parameters are DEATH-MONTH, DEATH-DAY, DEATH-YEAR; the diary entry is assumed
935 to be the name of the person. Date of death is on the *civil* calendar;
936 although the date of death is specified by the civil calendar, the proper
937 Hebrew calendar yahrzeit is determined. If `european-calendar-style' is t, the
938 order of the parameters is changed to DEATH-DAY, DEATH-MONTH, DEATH-YEAR.
939
940 An optional parameter MARK specifies a face or single-character string to
941 use when highlighting the day in the calendar."
942 (let* ((h-date (calendar-hebrew-from-absolute
943 (calendar-absolute-from-gregorian
944 (if european-calendar-style
945 (list death-day death-month death-year)
946 (list death-month death-day death-year)))))
947 (h-month (extract-calendar-month h-date))
948 (h-day (extract-calendar-day h-date))
949 (h-year (extract-calendar-year h-date))
950 (d (calendar-absolute-from-gregorian date))
951 (yr (extract-calendar-year (calendar-hebrew-from-absolute d)))
952 (diff (- yr h-year))
953 (y (hebrew-calendar-yahrzeit h-date yr)))
954 (if (and (> diff 0) (or (= y d) (= y (1+ d))))
955 (cons mark
956 (format "Yahrzeit of %s%s: %d%s anniversary"
957 entry
958 (if (= y d) "" " (evening)")
959 diff
960 (cond ((= (% diff 10) 1) "st")
961 ((= (% diff 10) 2) "nd")
962 ((= (% diff 10) 3) "rd")
963 (t "th")))))))
964
965 (defun diary-rosh-hodesh (&optional mark)
966 "Rosh Hodesh diary entry.
967 Entry applies if date is Rosh Hodesh, the day before, or the Saturday before.
968
969 An optional parameter MARK specifies a face or single-character string to
970 use when highlighting the day in the calendar."
971 (let* ((d (calendar-absolute-from-gregorian date))
972 (h-date (calendar-hebrew-from-absolute d))
973 (h-month (extract-calendar-month h-date))
974 (h-day (extract-calendar-day h-date))
975 (h-year (extract-calendar-year h-date))
976 (leap-year (hebrew-calendar-leap-year-p h-year))
977 (last-day (hebrew-calendar-last-day-of-month h-month h-year))
978 (h-month-names
979 (if leap-year
980 calendar-hebrew-month-name-array-leap-year
981 calendar-hebrew-month-name-array-common-year))
982 (this-month (aref h-month-names (1- h-month)))
983 (h-yesterday (extract-calendar-day
984 (calendar-hebrew-from-absolute (1- d)))))
985 (if (or (= h-day 30) (and (= h-day 1) (/= h-month 7)))
986 (cons mark
987 (format
988 "Rosh Hodesh %s"
989 (if (= h-day 30)
990 (format
991 "%s (first day)"
992 ;; next month must be in the same year since this
993 ;; month can't be the last month of the year since
994 ;; it has 30 days
995 (aref h-month-names h-month))
996 (if (= h-yesterday 30)
997 (format "%s (second day)" this-month)
998 this-month))))
999 (if (= (% d 7) 6) ;; Saturday--check for Shabbat Mevarchim
1000 (cons mark
1001 (cond ((and (> h-day 22) (/= h-month 6) (= 29 last-day))
1002 (format "Mevarchim Rosh Hodesh %s (%s)"
1003 (aref h-month-names
1004 (if (= h-month
1005 (hebrew-calendar-last-month-of-year
1006 h-year))
1007 0 h-month))
1008 (aref calendar-day-name-array (- 29 h-day))))
1009 ((and (< h-day 30) (> h-day 22) (= 30 last-day))
1010 (format "Mevarchim Rosh Hodesh %s (%s-%s)"
1011 (aref h-month-names h-month)
1012 (if (= h-day 29)
1013 "tomorrow"
1014 (aref calendar-day-name-array (- 29 h-day)))
1015 (aref calendar-day-name-array
1016 (% (- 30 h-day) 7))))))
1017 (if (and (= h-day 29) (/= h-month 6))
1018 (cons mark
1019 (format "Erev Rosh Hodesh %s"
1020 (aref h-month-names
1021 (if (= h-month
1022 (hebrew-calendar-last-month-of-year
1023 h-year))
1024 0 h-month)))))))))
1025
1026 (defvar hebrew-calendar-parashiot-names
1027 ["Bereshith" "Noah" "Lech L'cha" "Vayera" "Hayei Sarah" "Toledoth"
1028 "Vayetze" "Vayishlah" "Vayeshev" "Mikketz" "Vayiggash" "Vayhi"
1029 "Shemoth" "Vaera" "Bo" "Beshallah" "Yithro" "Mishpatim"
1030 "Terumah" "Tetzavveh" "Ki Tissa" "Vayakhel" "Pekudei" "Vayikra"
1031 "Tzav" "Shemini" "Tazria" "Metzora" "Aharei Moth" "Kedoshim"
1032 "Emor" "Behar" "Behukkotai" "Bemidbar" "Naso" "Behaalot'cha"
1033 "Shelah L'cha" "Korah" "Hukkath" "Balak" "Pinhas" "Mattoth"
1034 "Masei" "Devarim" "Vaethanan" "Ekev" "Reeh" "Shofetim"
1035 "Ki Tetze" "Ki Tavo" "Nitzavim" "Vayelech" "Haazinu"]
1036 "The names of the parashiot in the Torah.")
1037
1038 (defun hebrew-calendar-parasha-name (p)
1039 "Name(s) corresponding to parasha P."
1040 (if (arrayp p);; combined parasha
1041 (format "%s/%s"
1042 (aref hebrew-calendar-parashiot-names (aref p 0))
1043 (aref hebrew-calendar-parashiot-names (aref p 1)))
1044 (aref hebrew-calendar-parashiot-names p)))
1045
1046 (defun diary-parasha (&optional mark)
1047 "Parasha diary entry--entry applies if date is a Saturday.
1048
1049 An optional parameter MARK specifies a face or single-character string to
1050 use when highlighting the day in the calendar."
1051 (let ((d (calendar-absolute-from-gregorian date)))
1052 (if (= (% d 7) 6) ;; Saturday
1053 (let*
1054 ((h-year (extract-calendar-year
1055 (calendar-hebrew-from-absolute d)))
1056 (rosh-hashanah
1057 (calendar-absolute-from-hebrew (list 7 1 h-year)))
1058 (passover
1059 (calendar-absolute-from-hebrew (list 1 15 h-year)))
1060 (rosh-hashanah-day
1061 (aref calendar-day-name-array (% rosh-hashanah 7)))
1062 (passover-day
1063 (aref calendar-day-name-array (% passover 7)))
1064 (long-h (hebrew-calendar-long-heshvan-p h-year))
1065 (short-k (hebrew-calendar-short-kislev-p h-year))
1066 (type (cond ((and long-h (not short-k)) "complete")
1067 ((and (not long-h) short-k) "incomplete")
1068 (t "regular")))
1069 (year-format
1070 (symbol-value
1071 (intern (format "hebrew-calendar-year-%s-%s-%s" ;; keviah
1072 rosh-hashanah-day type passover-day))))
1073 (first-saturday ;; of Hebrew year
1074 (calendar-dayname-on-or-before 6 (+ 6 rosh-hashanah)))
1075 (saturday ;; which Saturday of the Hebrew year
1076 (/ (- d first-saturday) 7))
1077 (parasha (aref year-format saturday)))
1078 (if parasha
1079 (cons mark
1080 (format
1081 "Parashat %s"
1082 (if (listp parasha) ;; Israel differs from diaspora
1083 (if (car parasha)
1084 (format "%s (diaspora), %s (Israel)"
1085 (hebrew-calendar-parasha-name (car parasha))
1086 (hebrew-calendar-parasha-name (cdr parasha)))
1087 (format "%s (Israel)"
1088 (hebrew-calendar-parasha-name (cdr parasha))))
1089 (hebrew-calendar-parasha-name parasha)))))))))
1090
1091 ;; The seven ordinary year types (keviot)
1092
1093 (defconst hebrew-calendar-year-Saturday-incomplete-Sunday
1094 [nil 52 nil nil 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 [21 22]
1095 23 24 nil 25 [26 27] [28 29] 30 [31 32] 33 34 35 36 37 38 39 40 [41 42]
1096 43 44 45 46 47 48 49 50]
1097 "The structure of the parashiot.
1098 Hebrew year starts on Saturday, is `incomplete' (Heshvan and Kislev each have
1099 29 days), and has Passover start on Sunday.")
1100
1101 (defconst hebrew-calendar-year-Saturday-complete-Tuesday
1102 [nil 52 nil nil 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 [21 22]
1103 23 24 nil 25 [26 27] [28 29] 30 [31 32] 33 34 35 36 37 38 39 40 [41 42]
1104 43 44 45 46 47 48 49 [50 51]]
1105 "The structure of the parashiot.
1106 Hebrew year that starts on Saturday, is `complete' (Heshvan and Kislev each
1107 have 30 days), and has Passover start on Tuesday.")
1108
1109 (defconst hebrew-calendar-year-Monday-incomplete-Tuesday
1110 [51 52 nil 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 [21 22]
1111 23 24 nil 25 [26 27] [28 29] 30 [31 32] 33 34 35 36 37 38 39 40 [41 42]
1112 43 44 45 46 47 48 49 [50 51]]
1113 "The structure of the parashiot.
1114 Hebrew year that starts on Monday, is `incomplete' (Heshvan and Kislev each
1115 have 29 days), and has Passover start on Tuesday.")
1116
1117 (defconst hebrew-calendar-year-Monday-complete-Thursday
1118 [51 52 nil 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 [21 22]
1119 23 24 nil 25 [26 27] [28 29] 30 [31 32] 33 (nil . 34) (34 . 35) (35 . 36)
1120 (36 . 37) (37 . 38) ([38 39] . 39) 40 [41 42] 43 44 45 46 47 48 49 [50 51]]
1121 "The structure of the parashiot.
1122 Hebrew year that starts on Monday, is `complete' (Heshvan and Kislev each have
1123 30 days), and has Passover start on Thursday.")
1124
1125 (defconst hebrew-calendar-year-Tuesday-regular-Thursday
1126 [51 52 nil 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 [21 22]
1127 23 24 nil 25 [26 27] [28 29] 30 [31 32] 33 (nil . 34) (34 . 35) (35 . 36)
1128 (36 . 37) (37 . 38) ([38 39] . 39) 40 [41 42] 43 44 45 46 47 48 49 [50 51]]
1129 "The structure of the parashiot.
1130 Hebrew year that starts on Tuesday, is `regular' (Heshvan has 29 days and
1131 Kislev has 30 days), and has Passover start on Thursday.")
1132
1133 (defconst hebrew-calendar-year-Thursday-regular-Saturday
1134 [52 nil nil 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 [21 22] 23
1135 24 nil (nil . 25) (25 . [26 27]) ([26 27] . [28 29]) ([28 29] . 30)
1136 (30 . 31) ([31 32] . 32) 33 34 35 36 37 38 39 40 [41 42] 43 44 45 46 47 48
1137 49 50]
1138 "The structure of the parashiot.
1139 Hebrew year that starts on Thursday, is `regular' (Heshvan has 29 days and
1140 Kislev has 30 days), and has Passover start on Saturday.")
1141
1142 (defconst hebrew-calendar-year-Thursday-complete-Sunday
1143 [52 nil nil 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
1144 23 24 nil 25 [26 27] [28 29] 30 [31 32] 33 34 35 36 37 38 39 40 [41 42]
1145 43 44 45 46 47 48 49 50]
1146 "The structure of the parashiot.
1147 Hebrew year that starts on Thursday, is `complete' (Heshvan and Kislev each
1148 have 30 days), and has Passover start on Sunday.")
1149
1150 ;; The seven leap year types (keviot)
1151
1152 (defconst hebrew-calendar-year-Saturday-incomplete-Tuesday
1153 [nil 52 nil nil 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
1154 23 24 25 26 27 nil 28 29 30 31 32 33 34 35 36 37 38 39 40 [41 42]
1155 43 44 45 46 47 48 49 [50 51]]
1156 "The structure of the parashiot.
1157 Hebrew year that starts on Saturday, is `incomplete' (Heshvan and Kislev each
1158 have 29 days), and has Passover start on Tuesday.")
1159
1160 (defconst hebrew-calendar-year-Saturday-complete-Thursday
1161 [nil 52 nil nil 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
1162 23 24 25 26 27 nil 28 29 30 31 32 33 (nil . 34) (34 . 35) (35 . 36)
1163 (36 . 37) (37 . 38) ([38 39] . 39) 40 [41 42] 43 44 45 46 47 48 49 [50 51]]
1164 "The structure of the parashiot.
1165 Hebrew year that starts on Saturday, is `complete' (Heshvan and Kislev each
1166 have 30 days), and has Passover start on Thursday.")
1167
1168 (defconst hebrew-calendar-year-Monday-incomplete-Thursday
1169 [51 52 nil 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
1170 23 24 25 26 27 nil 28 29 30 31 32 33 (nil . 34) (34 . 35) (35 . 36)
1171 (36 . 37) (37 . 38) ([38 39] . 39) 40 [41 42] 43 44 45 46 47 48 49 [50 51]]
1172 "The structure of the parashiot.
1173 Hebrew year that starts on Monday, is `incomplete' (Heshvan and Kislev each
1174 have 29 days), and has Passover start on Thursday.")
1175
1176 (defconst hebrew-calendar-year-Monday-complete-Saturday
1177 [51 52 nil 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
1178 23 24 25 26 27 nil (nil . 28) (28 . 29) (29 . 30) (30 . 31) (31 . 32)
1179 (32 . 33) (33 . 34) (34 . 35) (35 . 36) (36 . 37) (37 . 38) (38 . 39)
1180 (39 . 40) (40 . 41) ([41 42] . 42) 43 44 45 46 47 48 49 50]
1181 "The structure of the parashiot.
1182 Hebrew year that starts on Monday, is `complete' (Heshvan and Kislev each have
1183 30 days), and has Passover start on Saturday.")
1184
1185 (defconst hebrew-calendar-year-Tuesday-regular-Saturday
1186 [51 52 nil 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
1187 23 24 25 26 27 nil (nil . 28) (28 . 29) (29 . 30) (30 . 31) (31 . 32)
1188 (32 . 33) (33 . 34) (34 . 35) (35 . 36) (36 . 37) (37 . 38) (38 . 39)
1189 (39 . 40) (40 . 41) ([41 42] . 42) 43 44 45 46 47 48 49 50]
1190 "The structure of the parashiot.
1191 Hebrew year that starts on Tuesday, is `regular' (Heshvan has 29 days and
1192 Kislev has 30 days), and has Passover start on Saturday.")
1193
1194 (defconst hebrew-calendar-year-Thursday-incomplete-Sunday
1195 [52 nil nil 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
1196 23 24 25 26 27 28 nil 29 30 31 32 33 34 35 36 37 38 39 40 41 42
1197 43 44 45 46 47 48 49 50]
1198 "The structure of the parashiot.
1199 Hebrew year that starts on Thursday, is `incomplete' (Heshvan and Kislev both
1200 have 29 days), and has Passover start on Sunday.")
1201
1202 (defconst hebrew-calendar-year-Thursday-complete-Tuesday
1203 [52 nil nil 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
1204 23 24 25 26 27 28 nil 29 30 31 32 33 34 35 36 37 38 39 40 41 42
1205 43 44 45 46 47 48 49 [50 51]]
1206 "The structure of the parashiot.
1207 Hebrew year that starts on Thursday, is `complete' (Heshvan and Kislev both
1208 have 30 days), and has Passover start on Tuesday.")
1209
1210 (provide 'cal-hebrew)
1211
1212 ;;; arch-tag: aaab6718-7712-42ac-a32d-28fe1f944f3c
1213 ;;; cal-hebrew.el ends here