(command_loop_1): Cancel echoing etc.
[emacs.git] / lisp / calendar / cal-hebrew.el
blob23e6d694b08640760c416d1f6d53e77131fd6ad9
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 (+ abs-p 12))
445 "Yom HaShoah")
446 (list (calendar-gregorian-from-absolute
447 (if (zerop (% abs-p 7))
448 (+ abs-p 18)
449 (if (= (% abs-p 7) 6)
450 (+ abs-p 19)
451 (+ abs-p 20))))
452 "Yom HaAtzma'ut")
453 (list (calendar-gregorian-from-absolute (+ abs-p 33))
454 "Lag BaOmer")
455 (list (calendar-gregorian-from-absolute (+ abs-p 43))
456 "Yom Yerushalim")
457 (list (calendar-gregorian-from-absolute (+ abs-p 49))
458 "Erev Shavuot")
459 (list (calendar-gregorian-from-absolute (+ abs-p 51))
460 "Shavuot (second day)")))
461 (output-list
462 (filter-visible-calendar-holidays mandatory)))
463 (if all-hebrew-calendar-holidays
464 (setq output-list
465 (append
466 (filter-visible-calendar-holidays optional)
467 output-list)))
468 output-list)))
470 (defun holiday-tisha-b-av-etc ()
471 "List of dates around Tisha B'Av, as visible in calendar window."
472 (if (or (< displayed-month 5)
473 (> displayed-month 9))
474 nil;; None of the dates is visible
475 (let* ((abs-t-a (calendar-absolute-from-hebrew
476 (list 5 9 (+ displayed-year 3760)))))
478 (filter-visible-calendar-holidays
479 (list
480 (list (calendar-gregorian-from-absolute
481 (if (= (% abs-t-a 7) 6) (- abs-t-a 20) (- abs-t-a 21)))
482 "Tzom Tammuz")
483 (list (calendar-gregorian-from-absolute
484 (calendar-dayname-on-or-before 6 abs-t-a))
485 "Shabbat Hazon")
486 (list (calendar-gregorian-from-absolute
487 (if (= (% abs-t-a 7) 6) (1+ abs-t-a) abs-t-a))
488 "Tisha B'Av")
489 (list (calendar-gregorian-from-absolute
490 (calendar-dayname-on-or-before 6 (+ abs-t-a 7)))
491 "Shabbat Nahamu"))))))
493 (defun list-hebrew-diary-entries ()
494 "Add any Hebrew date entries from the diary file to `diary-entries-list'.
495 Hebrew date diary entries must be prefaced by `hebrew-diary-entry-symbol'
496 \(normally an `H'). The same diary date forms govern the style of the Hebrew
497 calendar entries, except that the Hebrew month names must be spelled in full.
498 The Hebrew months are numbered from 1 to 13 with Nisan being 1, 12 being
499 Adar I and 13 being Adar II; you must use `Adar I' if you want Adar of a
500 common Hebrew year. If a Hebrew date diary entry begins with a
501 `diary-nonmarking-symbol', the entry will appear in the diary listing, but will
502 not be marked in the calendar. This function is provided for use with the
503 `nongregorian-diary-listing-hook'."
504 (if (< 0 number)
505 (let ((buffer-read-only nil)
506 (diary-modified (buffer-modified-p))
507 (gdate original-date)
508 (mark (regexp-quote diary-nonmarking-symbol)))
509 (calendar-for-loop i from 1 to number do
510 (let* ((d diary-date-forms)
511 (hdate (calendar-hebrew-from-absolute
512 (calendar-absolute-from-gregorian gdate)))
513 (month (extract-calendar-month hdate))
514 (day (extract-calendar-day hdate))
515 (year (extract-calendar-year hdate)))
516 (while d
517 (let*
518 ((date-form (if (equal (car (car d)) 'backup)
519 (cdr (car d))
520 (car d)))
521 (backup (equal (car (car d)) 'backup))
522 (dayname
523 (concat
524 (calendar-day-name gdate) "\\|"
525 (substring (calendar-day-name gdate) 0 3) ".?"))
526 (calendar-month-name-array
527 calendar-hebrew-month-name-array-leap-year)
528 (monthname
529 (concat
530 "\\*\\|"
531 (calendar-month-name month)))
532 (month (concat "\\*\\|0*" (int-to-string month)))
533 (day (concat "\\*\\|0*" (int-to-string day)))
534 (year
535 (concat
536 "\\*\\|0*" (int-to-string year)
537 (if abbreviated-calendar-year
538 (concat "\\|" (int-to-string (% year 100)))
539 "")))
540 (regexp
541 (concat
542 "\\(\\`\\|\^M\\|\n\\)" mark "?"
543 (regexp-quote hebrew-diary-entry-symbol)
544 "\\("
545 (mapconcat 'eval date-form "\\)\\(")
546 "\\)"))
547 (case-fold-search t))
548 (goto-char (point-min))
549 (while (re-search-forward regexp nil t)
550 (if backup (re-search-backward "\\<" nil t))
551 (if (and (or (char-equal (preceding-char) ?\^M)
552 (char-equal (preceding-char) ?\n))
553 (not (looking-at " \\|\^I")))
554 ;; Diary entry that consists only of date.
555 (backward-char 1)
556 ;; Found a nonempty diary entry--make it visible and
557 ;; add it to the list.
558 (let ((entry-start (point))
559 (date-start))
560 (re-search-backward "\^M\\|\n\\|\\`")
561 (setq date-start (point))
562 (re-search-forward "\^M\\|\n" nil t 2)
563 (while (looking-at " \\|\^I")
564 (re-search-forward "\^M\\|\n" nil t))
565 (backward-char 1)
566 (subst-char-in-region date-start (point) ?\^M ?\n t)
567 (add-to-diary-list
568 gdate (buffer-substring entry-start (point)))))))
569 (setq d (cdr d))))
570 (setq gdate
571 (calendar-gregorian-from-absolute
572 (1+ (calendar-absolute-from-gregorian gdate)))))
573 (set-buffer-modified-p diary-modified))
574 (goto-char (point-min))))
576 (defun mark-hebrew-diary-entries ()
577 "Mark days in the calendar window that have Hebrew date diary entries.
578 Each entry in diary-file (or included files) visible in the calendar window
579 is marked. Hebrew date entries are prefaced by a hebrew-diary-entry-symbol
580 \(normally an `H'). The same diary-date-forms govern the style of the Hebrew
581 calendar entries, except that the Hebrew month names must be spelled in full.
582 The Hebrew months are numbered from 1 to 13 with Nisan being 1, 12 being
583 Adar I and 13 being Adar II; you must use `Adar I' if you want Adar of a
584 common Hebrew year. Hebrew date diary entries that begin with a
585 diary-nonmarking symbol will not be marked in the calendar. This function
586 is provided for use as part of the nongregorian-diary-marking-hook."
587 (let ((d diary-date-forms))
588 (while d
589 (let*
590 ((date-form (if (equal (car (car d)) 'backup)
591 (cdr (car d))
592 (car d)));; ignore 'backup directive
593 (dayname (diary-name-pattern calendar-day-name-array))
594 (monthname
595 (concat
596 (diary-name-pattern calendar-hebrew-month-name-array-leap-year t)
597 "\\|\\*"))
598 (month "[0-9]+\\|\\*")
599 (day "[0-9]+\\|\\*")
600 (year "[0-9]+\\|\\*")
601 (l (length date-form))
602 (d-name-pos (- l (length (memq 'dayname date-form))))
603 (d-name-pos (if (/= l d-name-pos) (+ 2 d-name-pos)))
604 (m-name-pos (- l (length (memq 'monthname date-form))))
605 (m-name-pos (if (/= l m-name-pos) (+ 2 m-name-pos)))
606 (d-pos (- l (length (memq 'day date-form))))
607 (d-pos (if (/= l d-pos) (+ 2 d-pos)))
608 (m-pos (- l (length (memq 'month date-form))))
609 (m-pos (if (/= l m-pos) (+ 2 m-pos)))
610 (y-pos (- l (length (memq 'year date-form))))
611 (y-pos (if (/= l y-pos) (+ 2 y-pos)))
612 (regexp
613 (concat
614 "\\(\\`\\|\^M\\|\n\\)"
615 (regexp-quote hebrew-diary-entry-symbol)
616 "\\("
617 (mapconcat 'eval date-form "\\)\\(")
618 "\\)"))
619 (case-fold-search t))
620 (goto-char (point-min))
621 (while (re-search-forward regexp nil t)
622 (let* ((dd-name
623 (if d-name-pos
624 (buffer-substring
625 (match-beginning d-name-pos)
626 (match-end d-name-pos))))
627 (mm-name
628 (if m-name-pos
629 (buffer-substring
630 (match-beginning m-name-pos)
631 (match-end m-name-pos))))
632 (mm (string-to-int
633 (if m-pos
634 (buffer-substring
635 (match-beginning m-pos)
636 (match-end m-pos))
637 "")))
638 (dd (string-to-int
639 (if d-pos
640 (buffer-substring
641 (match-beginning d-pos)
642 (match-end d-pos))
643 "")))
644 (y-str (if y-pos
645 (buffer-substring
646 (match-beginning y-pos)
647 (match-end y-pos))))
648 (yy (if (not y-str)
650 (if (and (= (length y-str) 2)
651 abbreviated-calendar-year)
652 (let* ((current-y
653 (extract-calendar-year
654 (calendar-hebrew-from-absolute
655 (calendar-absolute-from-gregorian
656 (calendar-current-date)))))
657 (y (+ (string-to-int y-str)
658 (* 100 (/ current-y 100)))))
659 (if (> (- y current-y) 50)
660 (- y 100)
661 (if (> (- current-y y) 50)
662 (+ y 100)
663 y)))
664 (string-to-int y-str)))))
665 (if dd-name
666 (mark-calendar-days-named
667 (cdr (assoc (capitalize (substring dd-name 0 3))
668 (calendar-make-alist
669 calendar-day-name-array
671 '(lambda (x) (substring x 0 3))))))
672 (if mm-name
673 (if (string-equal mm-name "*")
674 (setq mm 0)
675 (setq
677 (cdr
678 (assoc
679 (capitalize mm-name)
680 (calendar-make-alist
681 calendar-hebrew-month-name-array-leap-year))))))
682 (mark-hebrew-calendar-date-pattern mm dd yy)))))
683 (setq d (cdr d)))))
685 (defun mark-hebrew-calendar-date-pattern (month day year)
686 "Mark dates in calendar window that conform to Hebrew date MONTH/DAY/YEAR.
687 A value of 0 in any position is a wildcard."
688 (save-excursion
689 (set-buffer calendar-buffer)
690 (if (and (/= 0 month) (/= 0 day))
691 (if (/= 0 year)
692 ;; Fully specified Hebrew date.
693 (let ((date (calendar-gregorian-from-absolute
694 (calendar-absolute-from-hebrew
695 (list month day year)))))
696 (if (calendar-date-is-visible-p date)
697 (mark-visible-calendar-date date)))
698 ;; Month and day in any year--this taken from the holiday stuff.
699 (if (memq displayed-month;; This test is only to speed things up a
700 (list ;; bit; it works fine without the test too.
701 (if (< 11 month) (- month 11) (+ month 1))
702 (if (< 10 month) (- month 10) (+ month 2))
703 (if (< 9 month) (- month 9) (+ month 3))
704 (if (< 8 month) (- month 8) (+ month 4))
705 (if (< 7 month) (- month 7) (+ month 5))))
706 (let ((m1 displayed-month)
707 (y1 displayed-year)
708 (m2 displayed-month)
709 (y2 displayed-year)
710 (year))
711 (increment-calendar-month m1 y1 -1)
712 (increment-calendar-month m2 y2 1)
713 (let* ((start-date (calendar-absolute-from-gregorian
714 (list m1 1 y1)))
715 (end-date (calendar-absolute-from-gregorian
716 (list m2
717 (calendar-last-day-of-month m2 y2)
718 y2)))
719 (hebrew-start
720 (calendar-hebrew-from-absolute start-date))
721 (hebrew-end (calendar-hebrew-from-absolute end-date))
722 (hebrew-y1 (extract-calendar-year hebrew-start))
723 (hebrew-y2 (extract-calendar-year hebrew-end)))
724 (setq year (if (< 6 month) hebrew-y2 hebrew-y1))
725 (let ((date (calendar-gregorian-from-absolute
726 (calendar-absolute-from-hebrew
727 (list month day year)))))
728 (if (calendar-date-is-visible-p date)
729 (mark-visible-calendar-date date)))))))
730 ;; Not one of the simple cases--check all visible dates for match.
731 ;; Actually, the following code takes care of ALL of the cases, but
732 ;; it's much too slow to be used for the simple (common) cases.
733 (let ((m displayed-month)
734 (y displayed-year)
735 (first-date)
736 (last-date))
737 (increment-calendar-month m y -1)
738 (setq first-date
739 (calendar-absolute-from-gregorian
740 (list m 1 y)))
741 (increment-calendar-month m y 2)
742 (setq last-date
743 (calendar-absolute-from-gregorian
744 (list m (calendar-last-day-of-month m y) y)))
745 (calendar-for-loop date from first-date to last-date do
746 (let* ((h-date (calendar-hebrew-from-absolute date))
747 (h-month (extract-calendar-month h-date))
748 (h-day (extract-calendar-day h-date))
749 (h-year (extract-calendar-year h-date)))
750 (and (or (zerop month)
751 (= month h-month))
752 (or (zerop day)
753 (= day h-day))
754 (or (zerop year)
755 (= year h-year))
756 (mark-visible-calendar-date
757 (calendar-gregorian-from-absolute date)))))))))
759 (defun insert-hebrew-diary-entry (arg)
760 "Insert a diary entry.
761 For the Hebrew date corresponding to the date indicated by point.
762 Prefix arg will make the entry nonmarking."
763 (interactive "P")
764 (let* ((calendar-month-name-array
765 calendar-hebrew-month-name-array-leap-year))
766 (make-diary-entry
767 (concat
768 hebrew-diary-entry-symbol
769 (calendar-date-string
770 (calendar-hebrew-from-absolute
771 (calendar-absolute-from-gregorian
772 (calendar-cursor-to-date t)))
773 nil t))
774 arg)))
776 (defun insert-monthly-hebrew-diary-entry (arg)
777 "Insert a monthly diary entry.
778 For the day of the Hebrew month corresponding to the date indicated by point.
779 Prefix arg will make the entry nonmarking."
780 (interactive "P")
781 (let* ((calendar-date-display-form
782 (if european-calendar-style '(day " * ") '("* " day )))
783 (calendar-month-name-array
784 calendar-hebrew-month-name-array-leap-year))
785 (make-diary-entry
786 (concat
787 hebrew-diary-entry-symbol
788 (calendar-date-string
789 (calendar-hebrew-from-absolute
790 (calendar-absolute-from-gregorian
791 (calendar-cursor-to-date t)))))
792 arg)))
794 (defun insert-yearly-hebrew-diary-entry (arg)
795 "Insert an annual diary entry.
796 For the day of the Hebrew year corresponding to the date indicated by point.
797 Prefix arg will make the entry nonmarking."
798 (interactive "P")
799 (let* ((calendar-date-display-form
800 (if european-calendar-style
801 '(day " " monthname)
802 '(monthname " " day)))
803 (calendar-month-name-array
804 calendar-hebrew-month-name-array-leap-year))
805 (make-diary-entry
806 (concat
807 hebrew-diary-entry-symbol
808 (calendar-date-string
809 (calendar-hebrew-from-absolute
810 (calendar-absolute-from-gregorian
811 (calendar-cursor-to-date t)))))
812 arg)))
814 ;;;###autoload
815 (defun list-yahrzeit-dates (death-date start-year end-year)
816 "List Yahrzeit dates for *Gregorian* DEATH-DATE from START-YEAR to END-YEAR.
817 When called interactively from the calendar window, the date of death is taken
818 from the cursor position."
819 (interactive
820 (let* ((death-date
821 (if (equal (current-buffer) (get-buffer calendar-buffer))
822 (calendar-cursor-to-date)
823 (let* ((today (calendar-current-date))
824 (year (calendar-read
825 "Year of death (>0): "
826 '(lambda (x) (> x 0))
827 (int-to-string (extract-calendar-year today))))
828 (month-array calendar-month-name-array)
829 (completion-ignore-case t)
830 (month (cdr (assoc
831 (capitalize
832 (completing-read
833 "Month of death (name): "
834 (mapcar 'list (append month-array nil))
835 nil t))
836 (calendar-make-alist
837 month-array 1 'capitalize))))
838 (last (calendar-last-day-of-month month year))
839 (day (calendar-read
840 (format "Day of death (1-%d): " last)
841 '(lambda (x) (and (< 0 x) (<= x last))))))
842 (list month day year))))
843 (death-year (extract-calendar-year death-date))
844 (start-year (calendar-read
845 (format "Starting year of Yahrzeit table (>%d): "
846 death-year)
847 '(lambda (x) (> x death-year))
848 (int-to-string (1+ death-year))))
849 (end-year (calendar-read
850 (format "Ending year of Yahrzeit table (>=%d): "
851 start-year)
852 '(lambda (x) (>= x start-year)))))
853 (list death-date start-year end-year)))
854 (message "Computing yahrzeits...")
855 (let* ((yahrzeit-buffer "*Yahrzeits*")
856 (h-date (calendar-hebrew-from-absolute
857 (calendar-absolute-from-gregorian death-date)))
858 (h-month (extract-calendar-month h-date))
859 (h-day (extract-calendar-day h-date))
860 (h-year (extract-calendar-year h-date)))
861 (set-buffer (get-buffer-create yahrzeit-buffer))
862 (setq buffer-read-only nil)
863 (calendar-set-mode-line
864 (format "Yahrzeit dates for %s = %s"
865 (calendar-date-string death-date)
866 (let ((calendar-month-name-array
867 (if (hebrew-calendar-leap-year-p h-year)
868 calendar-hebrew-month-name-array-leap-year
869 calendar-hebrew-month-name-array-common-year)))
870 (calendar-date-string h-date nil t))))
871 (erase-buffer)
872 (goto-char (point-min))
873 (calendar-for-loop i from start-year to end-year do
874 (insert
875 (calendar-date-string
876 (calendar-gregorian-from-absolute
877 (hebrew-calendar-yahrzeit
878 h-date
879 (extract-calendar-year
880 (calendar-hebrew-from-absolute
881 (calendar-absolute-from-gregorian (list 1 1 i))))))) "\n"))
882 (goto-char (point-min))
883 (set-buffer-modified-p nil)
884 (setq buffer-read-only t)
885 (display-buffer yahrzeit-buffer)
886 (message "Computing yahrzeits...done")))
888 (defun diary-hebrew-date ()
889 "Hebrew calendar equivalent of date diary entry."
890 (format "Hebrew date (until sunset): %s" (calendar-hebrew-date-string date)))
892 (defun diary-omer ()
893 "Omer count diary entry.
894 Entry applies if date is within 50 days after Passover."
895 (let* ((passover
896 (calendar-absolute-from-hebrew
897 (list 1 15 (+ (extract-calendar-year date) 3760))))
898 (omer (- (calendar-absolute-from-gregorian date) passover))
899 (week (/ omer 7))
900 (day (% omer 7)))
901 (if (and (> omer 0) (< omer 50))
902 (format "Day %d%s of the omer (until sunset)"
903 omer
904 (if (zerop week)
906 (format ", that is, %d week%s%s"
907 week
908 (if (= week 1) "" "s")
909 (if (zerop day)
911 (format " and %d day%s"
912 day (if (= day 1) "" "s")))))))))
914 (defun diary-yahrzeit (death-month death-day death-year)
915 "Yahrzeit diary entry--entry applies if date is yahrzeit or the day before.
916 Parameters are DEATH-MONTH, DEATH-DAY, DEATH-YEAR; the diary entry is assumed
917 to be the name of the person. Date of death is on the *civil* calendar;
918 although the date of death is specified by the civil calendar, the proper
919 Hebrew calendar yahrzeit is determined. If `european-calendar-style' is t, the
920 order of the parameters is changed to DEATH-DAY, DEATH-MONTH, DEATH-YEAR."
921 (let* ((h-date (calendar-hebrew-from-absolute
922 (calendar-absolute-from-gregorian
923 (if european-calendar-style
924 (list death-day death-month death-year)
925 (list death-month death-day death-year)))))
926 (h-month (extract-calendar-month h-date))
927 (h-day (extract-calendar-day h-date))
928 (h-year (extract-calendar-year h-date))
929 (d (calendar-absolute-from-gregorian date))
930 (yr (extract-calendar-year (calendar-hebrew-from-absolute d)))
931 (diff (- yr h-year))
932 (y (hebrew-calendar-yahrzeit h-date yr)))
933 (if (and (> diff 0) (or (= y d) (= y (1+ d))))
934 (format "Yahrzeit of %s%s: %d%s anniversary"
935 entry
936 (if (= y d) "" " (evening)")
937 diff
938 (cond ((= (% diff 10) 1) "st")
939 ((= (% diff 10) 2) "nd")
940 ((= (% diff 10) 3) "rd")
941 (t "th"))))))
943 (defun diary-rosh-hodesh ()
944 "Rosh Hodesh diary entry.
945 Entry applies if date is Rosh Hodesh, the day before, or the Saturday before."
946 (let* ((d (calendar-absolute-from-gregorian date))
947 (h-date (calendar-hebrew-from-absolute d))
948 (h-month (extract-calendar-month h-date))
949 (h-day (extract-calendar-day h-date))
950 (h-year (extract-calendar-year h-date))
951 (leap-year (hebrew-calendar-leap-year-p h-year))
952 (last-day (hebrew-calendar-last-day-of-month h-month h-year))
953 (h-month-names
954 (if leap-year
955 calendar-hebrew-month-name-array-leap-year
956 calendar-hebrew-month-name-array-common-year))
957 (this-month (aref h-month-names (1- h-month)))
958 (h-yesterday (extract-calendar-day
959 (calendar-hebrew-from-absolute (1- d)))))
960 (if (or (= h-day 30) (and (= h-day 1) (/= h-month 7)))
961 (format
962 "Rosh Hodesh %s"
963 (if (= h-day 30)
964 (format
965 "%s (first day)"
966 ;; next month must be in the same year since this
967 ;; month can't be the last month of the year since
968 ;; it has 30 days
969 (aref h-month-names h-month))
970 (if (= h-yesterday 30)
971 (format "%s (second day)" this-month)
972 this-month)))
973 (if (= (% d 7) 6);; Saturday--check for Shabbat Mevarhim
974 (cond ((and (> h-day 22) (/= h-month 6) (= 29 last-day))
975 (format "Mevarhim Rosh Hodesh %s (%s)"
976 (aref h-month-names
977 (if (= h-month
978 (hebrew-calendar-last-month-of-year
979 h-year))
980 0 h-month))
981 (aref calendar-day-name-array (- 29 h-day))))
982 ((and (< h-day 30) (> h-day 22) (= 30 last-day))
983 (format "Mevarhim Rosh Hodesh %s (%s-%s)"
984 (aref h-month-names h-month)
985 (if (= h-day 29)
986 "tomorrow"
987 (aref calendar-day-name-array (- 29 h-day)))
988 (aref calendar-day-name-array
989 (% (- 30 h-day) 7)))))
990 (if (and (= h-day 29) (/= h-month 6))
991 (format "Erev Rosh Hodesh %s"
992 (aref h-month-names
993 (if (= h-month
994 (hebrew-calendar-last-month-of-year
995 h-year))
996 0 h-month))))))))
998 (defun diary-parasha ()
999 "Parasha diary entry--entry applies if date is a Saturday."
1000 (let ((d (calendar-absolute-from-gregorian date)))
1001 (if (= (% d 7) 6);; Saturday
1002 (let*
1003 ((h-year (extract-calendar-year
1004 (calendar-hebrew-from-absolute d)))
1005 (rosh-hashanah
1006 (calendar-absolute-from-hebrew (list 7 1 h-year)))
1007 (passover
1008 (calendar-absolute-from-hebrew (list 1 15 h-year)))
1009 (rosh-hashanah-day
1010 (aref calendar-day-name-array (% rosh-hashanah 7)))
1011 (passover-day
1012 (aref calendar-day-name-array (% passover 7)))
1013 (long-h (hebrew-calendar-long-heshvan-p h-year))
1014 (short-k (hebrew-calendar-short-kislev-p h-year))
1015 (type (cond ((and long-h (not short-k)) "complete")
1016 ((and (not long-h) short-k) "incomplete")
1017 (t "regular")))
1018 (year-format
1019 (symbol-value
1020 (intern (format "hebrew-calendar-year-%s-%s-%s";; keviah
1021 rosh-hashanah-day type passover-day))))
1022 (first-saturday;; of Hebrew year
1023 (calendar-dayname-on-or-before 6 (+ 6 rosh-hashanah)))
1024 (saturday;; which Saturday of the Hebrew year
1025 (/ (- d first-saturday) 7))
1026 (parasha (aref year-format saturday)))
1027 (if parasha
1028 (format
1029 "Parashat %s"
1030 (if (listp parasha);; Israel differs from diaspora
1031 (if (car parasha)
1032 (format "%s (diaspora), %s (Israel)"
1033 (hebrew-calendar-parasha-name (car parasha))
1034 (hebrew-calendar-parasha-name (cdr parasha)))
1035 (format "%s (Israel)"
1036 (hebrew-calendar-parasha-name (cdr parasha))))
1037 (hebrew-calendar-parasha-name parasha))))))))
1039 (defvar hebrew-calendar-parashiot-names
1040 ["Bereshith" "Noah" "Lech L'cha" "Vayera" "Hayei Sarah" "Toledoth"
1041 "Vayetze" "Vayishlah" "Vayeshev" "Mikketz" "Vayiggash" "Vayhi"
1042 "Shemoth" "Vaera" "Bo" "Beshallah" "Yithro" "Mishpatim"
1043 "Terumah" "Tetzavveh" "Ki Tissa" "Vayakhel" "Pekudei" "Vayikra"
1044 "Tzav" "Shemini" "Tazria" "Metzora" "Aharei Moth" "Kedoshim"
1045 "Emor" "Behar" "Behukkotai" "Bemidbar" "Naso" "Behaalot'cha"
1046 "Shelah L'cha" "Korah" "Hukkath" "Balak" "Pinhas" "Mattoth"
1047 "Masei" "Devarim" "Vaethanan" "Ekev" "Reeh" "Shofetim"
1048 "Ki Tetze" "Ki Tavo" "Nitzavim" "Vayelech" "Haazinu"]
1049 "The names of the parashiot in the Torah.")
1051 ;; The seven ordinary year types (keviot)
1053 (defconst hebrew-calendar-year-Saturday-incomplete-Sunday
1054 [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]
1055 23 24 nil 25 [26 27] [28 29] 30 [31 32] 33 34 35 36 37 38 39 40 [41 42]
1056 43 44 45 46 47 48 49 50]
1057 "The structure of the parashiot.
1058 Hebrew year starts on Saturday, is `incomplete' (Heshvan and Kislev each have
1059 29 days), and has Passover start on Sunday.")
1061 (defconst hebrew-calendar-year-Saturday-complete-Tuesday
1062 [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]
1063 23 24 nil 25 [26 27] [28 29] 30 [31 32] 33 34 35 36 37 38 39 40 [41 42]
1064 43 44 45 46 47 48 49 [50 51]]
1065 "The structure of the parashiot.
1066 Hebrew year that starts on Saturday, is `complete' (Heshvan and Kislev each
1067 have 30 days), and has Passover start on Tuesday.")
1069 (defconst hebrew-calendar-year-Monday-incomplete-Tuesday
1070 [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]
1071 23 24 nil 25 [26 27] [28 29] 30 [31 32] 33 34 35 36 37 38 39 40 [41 42]
1072 43 44 45 46 47 48 49 [50 51]]
1073 "The structure of the parashiot.
1074 Hebrew year that starts on Monday, is `incomplete' (Heshvan and Kislev each
1075 have 29 days), and has Passover start on Tuesday.")
1077 (defconst hebrew-calendar-year-Monday-complete-Thursday
1078 [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]
1079 23 24 nil 25 [26 27] [28 29] 30 [31 32] 33 (nil . 34) (34 . 35) (35 . 36)
1080 (36 . 37) (37 . 38) ([38 39] . 39) 40 [41 42] 43 44 45 46 47 48 49 [50 51]]
1081 "The structure of the parashiot.
1082 Hebrew year that starts on Monday, is `complete' (Heshvan and Kislev each have
1083 30 days), and has Passover start on Thursday.")
1085 (defconst hebrew-calendar-year-Tuesday-regular-Thursday
1086 [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]
1087 23 24 nil 25 [26 27] [28 29] 30 [31 32] 33 (nil . 34) (34 . 35) (35 . 36)
1088 (36 . 37) (37 . 38) ([38 39] . 39) 40 [41 42] 43 44 45 46 47 48 49 [50 51]]
1089 "The structure of the parashiot.
1090 Hebrew year that starts on Tuesday, is `regular' (Heshvan has 29 days and
1091 Kislev has 30 days), and has Passover start on Thursday.")
1093 (defconst hebrew-calendar-year-Thursday-regular-Saturday
1094 [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
1095 24 nil (nil . 25) (25 . [26 27]) ([26 27] . [28 29]) ([28 29] . 30)
1096 (30 . 31) ([31 32] . 32) 33 34 35 36 37 38 39 40 [41 42] 43 44 45 46 47 48
1097 49 50]
1098 "The structure of the parashiot.
1099 Hebrew year that starts on Thursday, is `regular' (Heshvan has 29 days and
1100 Kislev has 30 days), and has Passover start on Saturday.")
1102 (defconst hebrew-calendar-year-Thursday-complete-Sunday
1103 [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
1104 23 24 nil 25 [26 27] [28 29] 30 [31 32] 33 34 35 36 37 38 39 40 [41 42]
1105 43 44 45 46 47 48 49 50]
1106 "The structure of the parashiot.
1107 Hebrew year that starts on Thursday, is `complete' (Heshvan and Kislev each
1108 have 30 days), and has Passover start on Sunday.")
1110 ;; The seven leap year types (keviot)
1112 (defconst hebrew-calendar-year-Saturday-incomplete-Tuesday
1113 [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
1114 23 24 25 26 27 nil 28 29 30 31 32 33 34 35 36 37 38 39 40 [41 42]
1115 43 44 45 46 47 48 49 [50 51]]
1116 "The structure of the parashiot.
1117 Hebrew year that starts on Saturday, is `incomplete' (Heshvan and Kislev each
1118 have 29 days), and has Passover start on Tuesday.")
1120 (defconst hebrew-calendar-year-Saturday-complete-Thursday
1121 [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
1122 23 24 25 26 27 nil 28 29 30 31 32 33 (nil . 34) (34 . 35) (35 . 36)
1123 (36 . 37) (37 . 38) ([38 39] . 39) 40 [41 42] 43 44 45 46 47 48 49 [50 51]]
1124 "The structure of the parashiot.
1125 Hebrew year that starts on Saturday, is `complete' (Heshvan and Kislev each
1126 have 30 days), and has Passover start on Thursday.")
1128 (defconst hebrew-calendar-year-Monday-incomplete-Thursday
1129 [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
1130 23 24 25 26 27 nil 28 29 30 31 32 33 (nil . 34) (34 . 35) (35 . 36)
1131 (36 . 37) (37 . 38) ([38 39] . 39) 40 [41 42] 43 44 45 46 47 48 49 [50 51]]
1132 "The structure of the parashiot.
1133 Hebrew year that starts on Monday, is `incomplete' (Heshvan and Kislev each
1134 have 29 days), and has Passover start on Thursday.")
1136 (defconst hebrew-calendar-year-Monday-complete-Saturday
1137 [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
1138 23 24 25 26 27 nil (nil . 28) (28 . 29) (29 . 30) (30 . 31) (31 . 32)
1139 (32 . 33) (33 . 34) (34 . 35) (35 . 36) (36 . 37) (37 . 38) (38 . 39)
1140 (39 . 40) (40 . 41) ([41 42] . 42) 43 44 45 46 47 48 49 50]
1141 "The structure of the parashiot.
1142 Hebrew year that starts on Monday, is `complete' (Heshvan and Kislev each have
1143 30 days), and has Passover start on Saturday.")
1145 (defconst hebrew-calendar-year-Tuesday-regular-Saturday
1146 [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
1147 23 24 25 26 27 nil (nil . 28) (28 . 29) (29 . 30) (30 . 31) (31 . 32)
1148 (32 . 33) (33 . 34) (34 . 35) (35 . 36) (36 . 37) (37 . 38) (38 . 39)
1149 (39 . 40) (40 . 41) ([41 42] . 42) 43 44 45 46 47 48 49 50]
1150 "The structure of the parashiot.
1151 Hebrew year that starts on Tuesday, is `regular' (Heshvan has 29 days and
1152 Kislev has 30 days), and has Passover start on Saturday.")
1154 (defconst hebrew-calendar-year-Thursday-incomplete-Sunday
1155 [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
1156 23 24 25 26 27 28 nil 29 30 31 32 33 34 35 36 37 38 39 40 41 42
1157 43 44 45 46 47 48 49 50]
1158 "The structure of the parashiot.
1159 Hebrew year that starts on Thursday, is `incomplete' (Heshvan and Kislev both
1160 have 29 days), and has Passover start on Sunday.")
1162 (defconst hebrew-calendar-year-Thursday-complete-Tuesday
1163 [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
1164 23 24 25 26 27 28 nil 29 30 31 32 33 34 35 36 37 38 39 40 41 42
1165 43 44 45 46 47 48 49 [50 51]]
1166 "The structure of the parashiot.
1167 Hebrew year that starts on Thursday, is `complete' (Heshvan and Kislev both
1168 have 30 days), and has Passover start on Tuesday.")
1170 (defun hebrew-calendar-parasha-name (p)
1171 "Name(s) corresponding to parasha P."
1172 (if (arrayp p);; combined parasha
1173 (format "%s/%s"
1174 (aref hebrew-calendar-parashiot-names (aref p 0))
1175 (aref hebrew-calendar-parashiot-names (aref p 1)))
1176 (aref hebrew-calendar-parashiot-names p)))
1178 (provide 'cal-hebrew)
1180 ;;; cal-hebrew.el ends here