Function: calendar-bahai-to-absolute
calendar-bahai-to-absolute is a byte-compiled function defined in
cal-bahai.el.gz.
Signature
(calendar-bahai-to-absolute DATE)
Documentation
Compute absolute date from Bahá’í date DATE.
The absolute date is the number of days elapsed since the (imaginary) Gregorian date Sunday, December 31, 1 BC.
Source Code
;; Defined in /usr/src/emacs/lisp/calendar/cal-bahai.el.gz
(defun calendar-bahai-to-absolute (date)
"Compute absolute date from Bahá’í date DATE.
The absolute date is the number of days elapsed since the (imaginary)
Gregorian date Sunday, December 31, 1 BC."
(let* ((month (calendar-extract-month date))
(day (calendar-extract-day date))
(year (calendar-extract-year date)))
(if (< year calendar-bahai-reform-year)
;; Pre-reform: use the old fixed calculation
(let* ((prior-years (+ (1- year) 1844))
(leap-days (- (+ (/ prior-years 4) ; leap days in prior years
(- (/ prior-years 100))
(/ prior-years 400))
calendar-bahai-leap-base)))
(+ (1- calendar-bahai-epoch) ; days before epoch
(* 365 (1- year)) ; days in prior years
leap-days
(calendar-sum m 1 (< m month) 19)
(if (= month 19)
;; For Ayyám-i-Há (day <= 0), adjust by (ayyam-ha-days - 1)
;; instead of ayyam-ha-days to match encoding
(if (<= day 0)
(1- (if (calendar-bahai-leap-year-p year) 5 4))
(if (calendar-bahai-leap-year-p year) 5 4))
0)
day)) ; days so far this month
;; Post-reform: use actual Naw-Rúz dates
(let ((year-start (calendar-bahai-nawruz year))
(ayyam-ha-days (if (calendar-bahai-leap-year-p year) 5 4)))
(+ year-start
-1 ; go back one day from start
;; Add days for complete months
(cond
((< month 19)
(+ (* 19 (1- month))
day))
;; Month 19, day <= 0: Ayyám-i-Há
((<= day 0)
(+ (* 19 18)
(+ day (1- ayyam-ha-days))))
;; Month 19, day > 0: month 'Alá'
(t
(+ (* 19 18)
ayyam-ha-days
day))))))))