Function: calendar-bahai-twin-holy-birthdays-for-year
calendar-bahai-twin-holy-birthdays-for-year is a byte-compiled
function defined in cal-bahai.el.gz.
Signature
(calendar-bahai-twin-holy-birthdays-for-year BAHAI-YEAR)
Documentation
Calculate Gregorian dates of the Twin Holy Birthdays for Bahá’í YEAR.
Returns a list of two Gregorian dates: (BAB-DATE BAHA-DATE). The dates are determined by the eighth new moon after Naw-Rúz, calculated for Tehran's timezone. The first day following the eighth new moon is the Birth of the Báb, and the second day is the Birth of Bahá’u’lláh.
Source Code
;; Defined in /usr/src/emacs/lisp/calendar/cal-bahai.el.gz
(defun calendar-bahai-twin-holy-birthdays-for-year (bahai-year)
"Calculate Gregorian dates of the Twin Holy Birthdays for Bahá’í YEAR.
Returns a list of two Gregorian dates: (BAB-DATE BAHA-DATE).
The dates are determined by the eighth new moon after Naw-Rúz,
calculated for Tehran's timezone. The first day following the
eighth new moon is the Birth of the Báb, and the second day is
the Birth of Bahá’u’lláh."
(let* ((calendar-time-zone calendar-bahai-tehran-timezone)
;; Disable DST for Tehran
(calendar-daylight-savings-starts nil)
(calendar-daylight-savings-ends nil)
;; Get absolute date of Naw-Rúz for this Bahá’í year
(nawruz-absolute (calendar-bahai-nawruz bahai-year))
;; Naw-Rúz starts at sunset on this date in Tehran
;; We need to find new moons that occur AFTER sunset on Naw-Rúz
(nawruz-greg (calendar-gregorian-from-absolute nawruz-absolute))
;; Get sunset time on Naw-Rúz in Tehran
(nawruz-sunset-data (let ((calendar-latitude calendar-bahai-tehran-latitude)
(calendar-longitude calendar-bahai-tehran-longitude))
(solar-sunrise-sunset nawruz-greg)))
(nawruz-sunset (or (car (cadr nawruz-sunset-data)) 18.0)) ; default 6pm
;; Convert Naw-Rúz sunset to Julian day
;; Absolute date is at midnight, add fraction for sunset time
(nawruz-julian (+ (calendar-astro-from-absolute nawruz-absolute)
(/ nawruz-sunset 24.0)))
;; Find the 8th new moon after Naw-Rúz sunset
(current-julian nawruz-julian)
eighth-new-moon)
;; Find 8 new moons after Naw-Rúz by iterating
(dotimes (_ 8)
(setq current-julian (lunar-new-moon-on-or-after current-julian))
(setq eighth-new-moon current-julian)
;; Move forward by at least one day to find the next new moon
;; (lunar cycle is ~29.5 days, so +1 is safe)
(setq current-julian (+ current-julian 1)))
;; Convert the eighth new moon to absolute date and time
(let* ((new-moon-abs-with-frac (calendar-astro-to-absolute eighth-new-moon))
(new-moon-absolute (floor new-moon-abs-with-frac))
(new-moon-time-frac (- new-moon-abs-with-frac new-moon-absolute))
(new-moon-time-hours (* 24 new-moon-time-frac))
(new-moon-greg (calendar-gregorian-from-absolute new-moon-absolute))
;; Get sunset time in Tehran for the day of the new moon
(sunset-data (let ((calendar-latitude calendar-bahai-tehran-latitude)
(calendar-longitude calendar-bahai-tehran-longitude)
(calendar-time-zone calendar-bahai-tehran-timezone))
(solar-sunrise-sunset new-moon-greg)))
;; solar-sunrise-sunset returns ((sunrise-time zone) (sunset-time zone) daylight)
(sunset-time (car (cadr sunset-data)))
;; Determine which civil day is the "first day following" the new moon
;; In Bahá’í calendar, days run from sunset to sunset.
;; If new moon occurs before sunset, the Bahá’í day starting at
;; sunset that evening begins the "first day following"
;; If new moon occurs after sunset, we're already in the next Bahá’í
;; day, so the "first day following" starts at the next sunset
(bab-absolute (if (and sunset-time (< new-moon-time-hours sunset-time))
(1+ new-moon-absolute) ; Next civil day
(+ new-moon-absolute 2))) ; Civil day after next
(baha-absolute (1+ bab-absolute)))
;; Return both dates as Gregorian dates
(list (calendar-gregorian-from-absolute bab-absolute)
(calendar-gregorian-from-absolute baha-absolute)))))