-;;; cal-hebrew.el --- calendar functions for the Hebrew calendar.
+;;; cal-hebrew.el --- calendar functions for the Hebrew calendar
-;; Copyright (C) 1995 Free Software Foundation, Inc.
+;; Copyright (C) 1995, 1997 Free Software Foundation, Inc.
;; Author: Nachum Dershowitz <nachum@cs.uiuc.edu>
;; Edward M. Reingold <reingold@cs.uiuc.edu>
;; This collection of functions implements the features of calendar.el and
;; diary.el that deal with the Hebrew calendar.
+;; Technical details of all the calendrical calculations can be found in
+;; ``Calendrical Calculations'' by Nachum Dershowitz and Edward M. Reingold,
+;; Cambridge University Press (1997).
+
;; Comments, corrections, and improvements should be sent to
;; Edward M. Reingold Department of Computer Science
;; (217) 333-6733 University of Illinois at Urbana-Champaign
day)))
(if ;; If Rosh HaShanah would occur on Sunday, Wednesday, or Friday
(memq (% alternative-day 7) (list 0 3 5))
- ;; Then postpone it one (more) day and return
+ ;; Then postpone it one (more) day and return
(1+ alternative-day)
- ;; Else return
+ ;; Else return
alternative-day)))
(defun hebrew-calendar-days-in-year (year)
calendar-hebrew-month-name-array-leap-year
calendar-hebrew-month-name-array-common-year))
(completion-ignore-case t)
- (month (cdr (assoc
- (capitalize
- (completing-read
- "Hebrew calendar month name: "
- (mapcar 'list (append month-array nil))
- (if (= year 3761)
- '(lambda (x)
- (let ((m (cdr
- (assoc
- (car x)
- (calendar-make-alist
- month-array)))))
- (< 0
- (calendar-absolute-from-hebrew
- (list m
- (hebrew-calendar-last-day-of-month
- m year)
- year))))))
-
- t))
- (calendar-make-alist month-array 1 'capitalize))))
+ (month (cdr (assoc-ignore-case
+ (completing-read
+ "Hebrew calendar month name: "
+ (mapcar 'list (append month-array nil))
+ (if (= year 3761)
+ '(lambda (x)
+ (let ((m (cdr
+ (assoc-ignore-case
+ (car x)
+ (calendar-make-alist
+ month-array)))))
+ (< 0
+ (calendar-absolute-from-hebrew
+ (list m
+ (hebrew-calendar-last-day-of-month
+ m year)
+ year))))))
+ t)
+ (calendar-make-alist month-array 1))))
(last (hebrew-calendar-last-day-of-month month year))
(first (if (and (= year 3761) (= month 10))
18 1))
(list (calendar-gregorian-from-absolute (+ abs-r-h 22))
"Simchat Torah")))
(optional
- (list
+ (list
(list (calendar-gregorian-from-absolute
(calendar-dayname-on-or-before 6 (- abs-r-h 4)))
"Selichot (night)")
(list (calendar-gregorian-from-absolute (+ abs-r-h 19))
"Hol Hamoed Sukkot (fourth day)")
(list (calendar-gregorian-from-absolute (+ abs-r-h 20))
- "Hoshannah Rabbah")))
+ "Hoshanah Rabbah")))
(output-list
(filter-visible-calendar-holidays mandatory)))
(if all-hebrew-calendar-holidays
(setq output-list
- (append
+ (append
(filter-visible-calendar-holidays optional)
output-list)))
output-list)))
(list (calendar-gregorian-from-absolute (+ abs-p 50))
"Shavuot")))
(optional
- (list
+ (list
(list (calendar-gregorian-from-absolute
(calendar-dayname-on-or-before 6 (- abs-p 43)))
"Shabbat Shekalim")
(list (calendar-gregorian-from-absolute (+ abs-p 33))
"Lag BaOmer")
(list (calendar-gregorian-from-absolute (+ abs-p 43))
- "Yom Yerushalim")
+ "Yom Yerushalaim")
(list (calendar-gregorian-from-absolute (+ abs-p 49))
"Erev Shavuot")
(list (calendar-gregorian-from-absolute (+ abs-p 51))
(filter-visible-calendar-holidays mandatory)))
(if all-hebrew-calendar-holidays
(setq output-list
- (append
+ (append
(filter-visible-calendar-holidays optional)
output-list)))
output-list)))
(list 5 9 (+ displayed-year 3760)))))
(filter-visible-calendar-holidays
- (list
+ (list
(list (calendar-gregorian-from-absolute
(if (= (% abs-t-a 7) 6) (- abs-t-a 20) (- abs-t-a 21)))
"Tzom Tammuz")
(mark (regexp-quote diary-nonmarking-symbol)))
(calendar-for-loop i from 1 to number do
(let* ((d diary-date-forms)
- (hdate (calendar-hebrew-from-absolute
+ (hdate (calendar-hebrew-from-absolute
(calendar-absolute-from-gregorian gdate)))
(month (extract-calendar-month hdate))
(day (extract-calendar-day hdate))
(string-to-int y-str)))))
(if dd-name
(mark-calendar-days-named
- (cdr (assoc (capitalize (substring dd-name 0 3))
- (calendar-make-alist
- calendar-day-name-array
- 0
- '(lambda (x) (substring x 0 3))))))
+ (cdr (assoc-ignore-case
+ (substring dd-name 0 3)
+ (calendar-make-alist
+ calendar-day-name-array
+ 0
+ '(lambda (x) (substring x 0 3))))))
(if mm-name
(if (string-equal mm-name "*")
(setq mm 0)
(setq
mm
- (cdr
- (assoc
- (capitalize mm-name)
- (calendar-make-alist
- calendar-hebrew-month-name-array-leap-year))))))
+ (cdr
+ (assoc-ignore-case
+ mm-name
+ (calendar-make-alist
+ calendar-hebrew-month-name-array-leap-year))))))
(mark-hebrew-calendar-date-pattern mm dd yy)))))
(setq d (cdr d)))))
(make-diary-entry
(concat
hebrew-diary-entry-symbol
- (calendar-date-string
+ (calendar-date-string
(calendar-hebrew-from-absolute
(calendar-absolute-from-gregorian
(calendar-cursor-to-date t)))
(make-diary-entry
(concat
hebrew-diary-entry-symbol
- (calendar-date-string
+ (calendar-date-string
(calendar-hebrew-from-absolute
(calendar-absolute-from-gregorian
(calendar-cursor-to-date t)))))
(make-diary-entry
(concat
hebrew-diary-entry-symbol
- (calendar-date-string
+ (calendar-date-string
(calendar-hebrew-from-absolute
(calendar-absolute-from-gregorian
(calendar-cursor-to-date t)))))
(int-to-string (extract-calendar-year today))))
(month-array calendar-month-name-array)
(completion-ignore-case t)
- (month (cdr (assoc
- (capitalize
- (completing-read
- "Month of death (name): "
- (mapcar 'list (append month-array nil))
- nil t))
- (calendar-make-alist
- month-array 1 'capitalize))))
+ (month (cdr (assoc-ignore-case
+ (completing-read
+ "Month of death (name): "
+ (mapcar 'list (append month-array nil))
+ nil t)
+ (calendar-make-alist month-array 1))))
(last (calendar-last-day-of-month month year))
(day (calendar-read
(format "Day of death (1-%d): " last)
"Hebrew calendar equivalent of date diary entry."
(format "Hebrew date (until sunset): %s" (calendar-hebrew-date-string date)))
-(defun diary-omer ()
+(defun diary-omer (&optional mark)
"Omer count diary entry.
-Entry applies if date is within 50 days after Passover."
+Entry applies if date is within 50 days after Passover.
+
+An optional parameter MARK specifies a face or single-character string to
+use when highlighting the day in the calendar."
(let* ((passover
(calendar-absolute-from-hebrew
(list 1 15 (+ (extract-calendar-year date) 3760))))
(week (/ omer 7))
(day (% omer 7)))
(if (and (> omer 0) (< omer 50))
- (format "Day %d%s of the omer (until sunset)"
- omer
- (if (zerop week)
- ""
- (format ", that is, %d week%s%s"
- week
- (if (= week 1) "" "s")
- (if (zerop day)
- ""
- (format " and %d day%s"
- day (if (= day 1) "" "s")))))))))
-
-(defun diary-yahrzeit (death-month death-day death-year)
+ (cons mark
+ (format "Day %d%s of the omer (until sunset)"
+ omer
+ (if (zerop week)
+ ""
+ (format ", that is, %d week%s%s"
+ week
+ (if (= week 1) "" "s")
+ (if (zerop day)
+ ""
+ (format " and %d day%s"
+ day (if (= day 1) "" "s"))))))))))
+
+(defun diary-yahrzeit (death-month death-day death-year &optional mark)
"Yahrzeit diary entry--entry applies if date is yahrzeit or the day before.
Parameters are DEATH-MONTH, DEATH-DAY, DEATH-YEAR; the diary entry is assumed
to be the name of the person. Date of death is on the *civil* calendar;
although the date of death is specified by the civil calendar, the proper
Hebrew calendar yahrzeit is determined. If `european-calendar-style' is t, the
-order of the parameters is changed to DEATH-DAY, DEATH-MONTH, DEATH-YEAR."
+order of the parameters is changed to DEATH-DAY, DEATH-MONTH, DEATH-YEAR.
+
+An optional parameter MARK specifies a face or single-character string to
+use when highlighting the day in the calendar."
(let* ((h-date (calendar-hebrew-from-absolute
(calendar-absolute-from-gregorian
(if european-calendar-style
(list death-day death-month death-year)
- (list death-month death-day death-year)))))
+ (list death-month death-day death-year)))))
(h-month (extract-calendar-month h-date))
(h-day (extract-calendar-day h-date))
(h-year (extract-calendar-year h-date))
(diff (- yr h-year))
(y (hebrew-calendar-yahrzeit h-date yr)))
(if (and (> diff 0) (or (= y d) (= y (1+ d))))
- (format "Yahrzeit of %s%s: %d%s anniversary"
- entry
- (if (= y d) "" " (evening)")
- diff
- (cond ((= (% diff 10) 1) "st")
- ((= (% diff 10) 2) "nd")
- ((= (% diff 10) 3) "rd")
- (t "th"))))))
-
-(defun diary-rosh-hodesh ()
+ (cons mark
+ (format "Yahrzeit of %s%s: %d%s anniversary"
+ entry
+ (if (= y d) "" " (evening)")
+ diff
+ (cond ((= (% diff 10) 1) "st")
+ ((= (% diff 10) 2) "nd")
+ ((= (% diff 10) 3) "rd")
+ (t "th")))))))
+
+(defun diary-rosh-hodesh (&optional mark)
"Rosh Hodesh diary entry.
-Entry applies if date is Rosh Hodesh, the day before, or the Saturday before."
+Entry applies if date is Rosh Hodesh, the day before, or the Saturday before.
+
+An optional parameter MARK specifies a face or single-character string to
+use when highlighting the day in the calendar."
(let* ((d (calendar-absolute-from-gregorian date))
(h-date (calendar-hebrew-from-absolute d))
(h-month (extract-calendar-month h-date))
(h-yesterday (extract-calendar-day
(calendar-hebrew-from-absolute (1- d)))))
(if (or (= h-day 30) (and (= h-day 1) (/= h-month 7)))
- (format
- "Rosh Hodesh %s"
- (if (= h-day 30)
- (format
- "%s (first day)"
- ;; next month must be in the same year since this
- ;; month can't be the last month of the year since
- ;; it has 30 days
- (aref h-month-names h-month))
- (if (= h-yesterday 30)
- (format "%s (second day)" this-month)
- this-month)))
- (if (= (% d 7) 6);; Saturday--check for Shabbat Mevarhim
- (cond ((and (> h-day 22) (/= h-month 6) (= 29 last-day))
- (format "Mevarhim Rosh Hodesh %s (%s)"
- (aref h-month-names
- (if (= h-month
- (hebrew-calendar-last-month-of-year
- h-year))
- 0 h-month))
- (aref calendar-day-name-array (- 29 h-day))))
- ((and (< h-day 30) (> h-day 22) (= 30 last-day))
- (format "Mevarhim Rosh Hodesh %s (%s-%s)"
- (aref h-month-names h-month)
- (if (= h-day 29)
- "tomorrow"
- (aref calendar-day-name-array (- 29 h-day)))
- (aref calendar-day-name-array
- (% (- 30 h-day) 7)))))
+ (cons mark
+ (format
+ "Rosh Hodesh %s"
+ (if (= h-day 30)
+ (format
+ "%s (first day)"
+ ;; next month must be in the same year since this
+ ;; month can't be the last month of the year since
+ ;; it has 30 days
+ (aref h-month-names h-month))
+ (if (= h-yesterday 30)
+ (format "%s (second day)" this-month)
+ this-month))))
+ (if (= (% d 7) 6) ;; Saturday--check for Shabbat Mevarchim
+ (cons mark
+ (cond ((and (> h-day 22) (/= h-month 6) (= 29 last-day))
+ (format "Mevarchim Rosh Hodesh %s (%s)"
+ (aref h-month-names
+ (if (= h-month
+ (hebrew-calendar-last-month-of-year
+ h-year))
+ 0 h-month))
+ (aref calendar-day-name-array (- 29 h-day))))
+ ((and (< h-day 30) (> h-day 22) (= 30 last-day))
+ (format "Mevarchim Rosh Hodesh %s (%s-%s)"
+ (aref h-month-names h-month)
+ (if (= h-day 29)
+ "tomorrow"
+ (aref calendar-day-name-array (- 29 h-day)))
+ (aref calendar-day-name-array
+ (% (- 30 h-day) 7))))))
(if (and (= h-day 29) (/= h-month 6))
- (format "Erev Rosh Hodesh %s"
- (aref h-month-names
- (if (= h-month
- (hebrew-calendar-last-month-of-year
- h-year))
- 0 h-month))))))))
-
-(defun diary-parasha ()
- "Parasha diary entry--entry applies if date is a Saturday."
+ (cons mark
+ (format "Erev Rosh Hodesh %s"
+ (aref h-month-names
+ (if (= h-month
+ (hebrew-calendar-last-month-of-year
+ h-year))
+ 0 h-month)))))))))
+
+(defun diary-parasha (&optional mark)
+ "Parasha diary entry--entry applies if date is a Saturday.
+
+An optional parameter MARK specifies a face or single-character string to
+use when highlighting the day in the calendar."
(let ((d (calendar-absolute-from-gregorian date)))
- (if (= (% d 7) 6);; Saturday
+ (if (= (% d 7) 6) ;; Saturday
(let*
((h-year (extract-calendar-year
(calendar-hebrew-from-absolute d)))
(t "regular")))
(year-format
(symbol-value
- (intern (format "hebrew-calendar-year-%s-%s-%s";; keviah
+ (intern (format "hebrew-calendar-year-%s-%s-%s" ;; keviah
rosh-hashanah-day type passover-day))))
- (first-saturday;; of Hebrew year
+ (first-saturday ;; of Hebrew year
(calendar-dayname-on-or-before 6 (+ 6 rosh-hashanah)))
- (saturday;; which Saturday of the Hebrew year
+ (saturday ;; which Saturday of the Hebrew year
(/ (- d first-saturday) 7))
(parasha (aref year-format saturday)))
(if parasha
- (format
- "Parashat %s"
- (if (listp parasha);; Israel differs from diaspora
- (if (car parasha)
- (format "%s (diaspora), %s (Israel)"
- (hebrew-calendar-parasha-name (car parasha))
- (hebrew-calendar-parasha-name (cdr parasha)))
- (format "%s (Israel)"
- (hebrew-calendar-parasha-name (cdr parasha))))
- (hebrew-calendar-parasha-name parasha))))))))
+ (cons mark
+ (format
+ "Parashat %s"
+ (if (listp parasha) ;; Israel differs from diaspora
+ (if (car parasha)
+ (format "%s (diaspora), %s (Israel)"
+ (hebrew-calendar-parasha-name (car parasha))
+ (hebrew-calendar-parasha-name (cdr parasha)))
+ (format "%s (Israel)"
+ (hebrew-calendar-parasha-name (cdr parasha))))
+ (hebrew-calendar-parasha-name parasha)))))))))
(defvar hebrew-calendar-parashiot-names
["Bereshith" "Noah" "Lech L'cha" "Vayera" "Hayei Sarah" "Toledoth"