Function: calendar-hebrew-elapsed-days

calendar-hebrew-elapsed-days is a byte-compiled function defined in cal-hebrew.el.gz.

Signature

(calendar-hebrew-elapsed-days YEAR)

Documentation

Days to mean conjunction of Tishri of Hebrew YEAR.

Measured from Sunday before start of Hebrew calendar.

Source Code

;; Defined in /usr/src/emacs/lisp/calendar/cal-hebrew.el.gz
(defun calendar-hebrew-elapsed-days (year)
  "Days to mean conjunction of Tishri of Hebrew YEAR.
Measured from Sunday before start of Hebrew calendar."
  (let* ((months-elapsed
          (+ (* 235 (/ (1- year) 19)) ; months in complete cycles so far
             (* 12 (% (1- year) 19))  ; regular months in this cycle
             (/ (1+ (* 7 (% (1- year) 19))) 19))) ; leap months this cycle
         (parts-elapsed (+ 204 (* 793 (% months-elapsed 1080))))
         (hours-elapsed (+ 5
                           (* 12 months-elapsed)
                           (* 793 (/ months-elapsed 1080))
                           (/ parts-elapsed 1080)))
         (parts                         ; conjunction parts
          (+ (* 1080 (% hours-elapsed 24)) (% parts-elapsed 1080)))
         (day                           ; conjunction day
          (+ 1 (* 29 months-elapsed) (/ hours-elapsed 24)))
         (alternative-day
          (if (or (>= parts 19440) ; if the new moon is at or after midday
                  (and (= (% day 7) 2)  ; ...or is on a Tuesday...
                       (>= parts 9924) ; at 9 hours, 204 parts or later...
                       ;; of a common year...
                       (not (calendar-hebrew-leap-year-p year)))
                  (and (= (% day 7) 1)  ; ...or is on a Monday...
                       (>= parts 16789) ; at 15 hours, 589 parts or later...
                       ;; at the end of a leap year.
                       (calendar-hebrew-leap-year-p (1- year))))
              ;; Then postpone Rosh HaShanah one day.
              (1+ day)
            ;; Else:
            day)))
    ;; If Rosh HaShanah would occur on Sunday, Wednesday, or Friday
    (if (memq (% alternative-day 7) (list 0 3 5))
        ;; Then postpone it one (more) day and return.
        (1+ alternative-day)
      ;; Else return.
      alternative-day)))