comparison lisp/calendar/cal-persia.el @ 93809:3ff2b47de8f2

Update for calendar.el name changes.
author Glenn Morris <rgm@gnu.org>
date Mon, 07 Apr 2008 01:59:37 +0000
parents df192d334c0a
children bf9ef749c23e
comparison
equal deleted inserted replaced
93808:2c72483f42c9 93809:3ff2b47de8f2
65 65
66 (defun calendar-persian-to-absolute (date) 66 (defun calendar-persian-to-absolute (date)
67 "Compute absolute date from Persian date DATE. 67 "Compute absolute date from Persian date DATE.
68 The absolute date is the number of days elapsed since the (imaginary) 68 The absolute date is the number of days elapsed since the (imaginary)
69 Gregorian date Sunday, December 31, 1 BC." 69 Gregorian date Sunday, December 31, 1 BC."
70 (let ((month (extract-calendar-month date)) 70 (let ((month (calendar-extract-month date))
71 (day (extract-calendar-day date)) 71 (day (calendar-extract-day date))
72 (year (extract-calendar-year date))) 72 (year (calendar-extract-year date)))
73 (if (< year 0) 73 (if (< year 0)
74 (+ (calendar-persian-to-absolute 74 (+ (calendar-persian-to-absolute
75 (list month day (1+ (mod year 2820)))) 75 (list month day (1+ (mod year 2820))))
76 (* 1029983 (floor year 2820))) 76 (* 1029983 (floor year 2820)))
77 (+ (1- calendar-persian-epoch) ; days before epoch 77 (+ (1- calendar-persian-epoch) ; days before epoch
147 (defun calendar-persian-date-string (&optional date) 147 (defun calendar-persian-date-string (&optional date)
148 "String of Persian date of Gregorian DATE, default today." 148 "String of Persian date of Gregorian DATE, default today."
149 (let* ((persian-date (calendar-persian-from-absolute 149 (let* ((persian-date (calendar-persian-from-absolute
150 (calendar-absolute-from-gregorian 150 (calendar-absolute-from-gregorian
151 (or date (calendar-current-date))))) 151 (or date (calendar-current-date)))))
152 (y (extract-calendar-year persian-date)) 152 (y (calendar-extract-year persian-date))
153 (m (extract-calendar-month persian-date)) 153 (m (calendar-extract-month persian-date))
154 (monthname (aref calendar-persian-month-name-array (1- m))) 154 (monthname (aref calendar-persian-month-name-array (1- m)))
155 (day (int-to-string (extract-calendar-day persian-date))) 155 (day (int-to-string (calendar-extract-day persian-date)))
156 (year (int-to-string y)) 156 (year (int-to-string y))
157 (month (int-to-string m)) 157 (month (int-to-string m))
158 dayname) 158 dayname)
159 (mapconcat 'eval calendar-date-display-form ""))) 159 (mapconcat 'eval calendar-date-display-form "")))
160 160
173 Reads a year, month, and day." 173 Reads a year, month, and day."
174 (let* ((year (calendar-read 174 (let* ((year (calendar-read
175 "Persian calendar year (not 0): " 175 "Persian calendar year (not 0): "
176 (lambda (x) (not (zerop x))) 176 (lambda (x) (not (zerop x)))
177 (int-to-string 177 (int-to-string
178 (extract-calendar-year 178 (calendar-extract-year
179 (calendar-persian-from-absolute 179 (calendar-persian-from-absolute
180 (calendar-absolute-from-gregorian 180 (calendar-absolute-from-gregorian
181 (calendar-current-date))))))) 181 (calendar-current-date)))))))
182 (completion-ignore-case t) 182 (completion-ignore-case t)
183 (month (cdr (assoc 183 (month (cdr (assoc