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