comparison lisp/calendar/cal-mayan.el @ 93001:6c85b8971fe3

(calendar-mayan-haab-to-string): Simplify. (calendar-mayan-tzolkin-from-absolute): Expand calendar-mod calls.
author Glenn Morris <rgm@gnu.org>
date Sun, 16 Mar 2008 01:58:15 +0000
parents cb0aac9dd8a3
children 0c5143f2417b
comparison
equal deleted inserted replaced
93000:36af1225602d 93001:6c85b8971fe3
213 (1- (calendar-absolute-from-gregorian (calendar-cursor-to-date)))))) 213 (1- (calendar-absolute-from-gregorian (calendar-cursor-to-date))))))
214 (or noecho (calendar-print-mayan-date))) 214 (or noecho (calendar-print-mayan-date)))
215 215
216 (defun calendar-mayan-haab-to-string (haab) 216 (defun calendar-mayan-haab-to-string (haab)
217 "Convert Mayan HAAB date (a pair) into its traditional written form." 217 "Convert Mayan HAAB date (a pair) into its traditional written form."
218 (let ((month (cdr haab)) 218 (let ((month (cdr haab)))
219 (day (car haab))) 219 (format "%d %s" (car haab) ; day
220 ;; 19th month consists of 5 special days 220 ;; 19th month consists of 5 special days
221 (if (= month 19) 221 (if (= month 19) "Uayeb"
222 (format "%d Uayeb" day)
223 (format "%d %s"
224 day
225 (aref calendar-mayan-haab-month-name-array (1- month)))))) 222 (aref calendar-mayan-haab-month-name-array (1- month))))))
226 223
227 (defun calendar-mayan-tzolkin-from-absolute (date) 224 (defun calendar-mayan-tzolkin-from-absolute (date)
228 "Convert absolute DATE into a Mayan tzolkin date (a pair)." 225 "Convert absolute DATE into a Mayan tzolkin date (a pair)."
229 (let* ((long-count (+ date calendar-mayan-days-before-absolute-zero)) 226 (let* ((long-count (+ date calendar-mayan-days-before-absolute-zero))
230 (day (calendar-mod 227 ;; Remainder on division by 13,20 with 13,20 instead of zero.
231 (+ long-count (car calendar-mayan-tzolkin-at-epoch)) 228 (day (1+ (mod
232 13)) 229 (1- (+ long-count (car calendar-mayan-tzolkin-at-epoch)))
233 (name (calendar-mod 230 13)))
234 (+ long-count (cdr calendar-mayan-tzolkin-at-epoch)) 231 (name (1+ (mod
235 20))) 232 (1- (+ long-count (cdr calendar-mayan-tzolkin-at-epoch)))
233 20))))
236 (cons day name))) 234 (cons day name)))
237 235
238 (defun calendar-mayan-tzolkin-difference (date1 date2) 236 (defun calendar-mayan-tzolkin-difference (date1 date2)
239 "Number of days from Mayan tzolkin DATE1 to next occurrence of tzolkin DATE2." 237 "Number of days from Mayan tzolkin DATE1 to next occurrence of tzolkin DATE2."
240 (let ((number-difference (- (car date2) (car date1))) 238 (let ((number-difference (- (car date2) (car date1)))