Function: calendar-persian-to-absolute

calendar-persian-to-absolute is an autoloaded and byte-compiled function defined in cal-persia.el.gz.

Signature

(calendar-persian-to-absolute DATE)

Documentation

Compute absolute date from Persian 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-persia.el.gz
(defun calendar-persian-to-absolute (date)
  "Compute absolute date from Persian 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 0)
        (+ (calendar-persian-to-absolute
            (list month day (1+ (mod year 2820))))
           (* 1029983 (floor year 2820)))
      (+ (1- calendar-persian-epoch)    ; days before epoch
         (* 365 (1- year))              ; days in prior years
         (* 683                  ; leap days in prior 2820-year cycles
            (floor (+ year 2345) 2820))
         (* 186                   ; leap days in prior 768 year cycles
            (floor (mod (+ year 2345) 2820) 768))
         (floor          ; leap years in current 768 or 516 year cycle
          (* 683 (mod (mod (+ year 2345) 2820) 768))
          2820)
         -568                 ; leap years in Persian years -2345...-1
         (calendar-sum        ; days in prior months this year
          m 1 (< m month)
          (calendar-persian-last-day-of-month m year))
         day))))                        ; days so far this month