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