Function: diary-hebrew-rosh-hodesh

diary-hebrew-rosh-hodesh is an autoloaded and byte-compiled function defined in cal-hebrew.el.gz.

Signature

(diary-hebrew-rosh-hodesh &optional MARK)

Documentation

Rosh Hodesh diary entry.

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.

Source Code

;; Defined in /usr/src/emacs/lisp/calendar/cal-hebrew.el.gz
;;;###diary-autoload
(defun diary-hebrew-rosh-hodesh (&optional mark)
  "Rosh Hodesh diary entry.
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 (calendar-extract-month h-date))
         (h-day (calendar-extract-day h-date))
         (h-year (calendar-extract-year h-date))
         (leap-year (calendar-hebrew-leap-year-p h-year))
         (last-day (calendar-hebrew-last-day-of-month h-month h-year))
         (h-month-names
          (if leap-year
              calendar-hebrew-month-name-array-leap-year
            calendar-hebrew-month-name-array-common-year))
         (this-month (aref h-month-names (1- h-month)))
         (h-yesterday (calendar-extract-day
                       (calendar-hebrew-from-absolute (1- d)))))
    (if (or (= h-day 30) (and (= h-day 1) (/= h-month 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
          (cond ((and (> h-day 22) (/= h-month 6) (= 29 last-day))
                 (cons mark
                       (format "Mevarchim Rosh Hodesh %s (%s)"
                               (aref h-month-names
                                     (if (= h-month
                                            (calendar-hebrew-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))
                 (cons mark
                       (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))
            (cons mark
                  (format "Erev Rosh Hodesh %s"
                          (aref h-month-names
                                (if (= h-month
                                       (calendar-hebrew-last-month-of-year
                                        h-year))
                                    0 h-month)))))))))