comparison lisp/calendar/cal-mayan.el @ 92636:f565309f0cab

(calendar-string-to-mayan-long-count) (calendar-mayan-haab-to-string, calendar-mayan-tzolkin-to-string) (calendar-read-mayan-haab-date, calendar-read-mayan-tzolkin-date) (calendar-next-calendar-round-date) (calendar-mayan-long-count-common-era): Doc fixes.
author Glenn Morris <rgm@gnu.org>
date Sat, 08 Mar 2008 20:32:13 +0000
parents 90e80e5b0c97
children 5e8d6a369c62
comparison
equal deleted inserted replaced
92635:fb3f66f11422 92636:f565309f0cab
91 (defun calendar-mayan-long-count-to-string (mayan-long-count) 91 (defun calendar-mayan-long-count-to-string (mayan-long-count)
92 "Convert MAYAN-LONG-COUNT into traditional written form." 92 "Convert MAYAN-LONG-COUNT into traditional written form."
93 (apply 'format (cons "%s.%s.%s.%s.%s" mayan-long-count))) 93 (apply 'format (cons "%s.%s.%s.%s.%s" mayan-long-count)))
94 94
95 (defun calendar-string-to-mayan-long-count (str) 95 (defun calendar-string-to-mayan-long-count (str)
96 "Given STR, a string of format \"%d.%d.%d.%d.%d\", return list of nums." 96 "Given STR, a string of format \"%d.%d.%d.%d.%d\", return list of numbers."
97 (let ((rlc nil) 97 (let ((rlc nil)
98 (c (length str)) 98 (c (length str))
99 (cc 0)) 99 (cc 0))
100 (condition-case condition 100 (condition-case condition
101 (progn 101 (progn
160 haab-date 160 haab-date
161 (1- (calendar-absolute-from-gregorian (calendar-cursor-to-date)))))) 161 (1- (calendar-absolute-from-gregorian (calendar-cursor-to-date))))))
162 (or noecho (calendar-print-mayan-date))) 162 (or noecho (calendar-print-mayan-date)))
163 163
164 (defun calendar-mayan-haab-to-string (haab) 164 (defun calendar-mayan-haab-to-string (haab)
165 "Convert Mayan haab date (a pair) into its traditional written form." 165 "Convert Mayan HAAB date (a pair) into its traditional written form."
166 (let ((month (cdr haab)) 166 (let ((month (cdr haab))
167 (day (car haab))) 167 (day (car haab)))
168 ;; 19th month consists of 5 special days 168 ;; 19th month consists of 5 special days
169 (if (= month 19) 169 (if (= month 19)
170 (format "%d Uayeb" day) 170 (format "%d Uayeb" day)
224 tzolkin-date 224 tzolkin-date
225 (1- (calendar-absolute-from-gregorian (calendar-cursor-to-date)))))) 225 (1- (calendar-absolute-from-gregorian (calendar-cursor-to-date))))))
226 (or noecho (calendar-print-mayan-date))) 226 (or noecho (calendar-print-mayan-date)))
227 227
228 (defun calendar-mayan-tzolkin-to-string (tzolkin) 228 (defun calendar-mayan-tzolkin-to-string (tzolkin)
229 "Convert Mayan tzolkin date (a pair) into its traditional written form." 229 "Convert Mayan TZOLKIN date (a pair) into its traditional written form."
230 (format "%d %s" 230 (format "%d %s"
231 (car tzolkin) 231 (car tzolkin)
232 (aref calendar-mayan-tzolkin-names-array (1- (cdr tzolkin))))) 232 (aref calendar-mayan-tzolkin-names-array (1- (cdr tzolkin)))))
233 233
234 (defun calendar-mayan-tzolkin-haab-on-or-before (tzolkin-date haab-date date) 234 (defun calendar-mayan-tzolkin-haab-on-or-before (tzolkin-date haab-date date)
250 (+ haab-difference (* 365 difference))) 250 (+ haab-difference (* 365 difference)))
251 18980)) 251 18980))
252 nil))) 252 nil)))
253 253
254 (defun calendar-read-mayan-haab-date () 254 (defun calendar-read-mayan-haab-date ()
255 "Prompt for a Mayan haab date" 255 "Prompt for a Mayan haab date."
256 (let* ((completion-ignore-case t) 256 (let* ((completion-ignore-case t)
257 (haab-day (calendar-read 257 (haab-day (calendar-read
258 "Haab kin (0-19): " 258 "Haab kin (0-19): "
259 (lambda (x) (and (>= x 0) (< x 20))))) 259 (lambda (x) (and (>= x 0) (< x 20)))))
260 (haab-month-list (append calendar-mayan-haab-month-name-array 260 (haab-month-list (append calendar-mayan-haab-month-name-array
266 nil t) 266 nil t)
267 (calendar-make-alist haab-month-list 1) t)))) 267 (calendar-make-alist haab-month-list 1) t))))
268 (cons haab-day haab-month))) 268 (cons haab-day haab-month)))
269 269
270 (defun calendar-read-mayan-tzolkin-date () 270 (defun calendar-read-mayan-tzolkin-date ()
271 "Prompt for a Mayan tzolkin date" 271 "Prompt for a Mayan tzolkin date."
272 (let* ((completion-ignore-case t) 272 (let* ((completion-ignore-case t)
273 (tzolkin-count (calendar-read 273 (tzolkin-count (calendar-read
274 "Tzolkin kin (1-13): " 274 "Tzolkin kin (1-13): "
275 (lambda (x) (and (> x 0) (< x 14))))) 275 (lambda (x) (and (> x 0) (< x 14)))))
276 (tzolkin-name-list (append calendar-mayan-tzolkin-names-array nil)) 276 (tzolkin-name-list (append calendar-mayan-tzolkin-names-array nil))
281 nil t) 281 nil t)
282 (calendar-make-alist tzolkin-name-list 1) t)))) 282 (calendar-make-alist tzolkin-name-list 1) t))))
283 (cons tzolkin-count tzolkin-name))) 283 (cons tzolkin-count tzolkin-name)))
284 284
285 ;;;###autoload 285 ;;;###autoload
286 (defun calendar-next-calendar-round-date 286 (defun calendar-next-calendar-round-date (tzolkin-date haab-date
287 (tzolkin-date haab-date &optional noecho) 287 &optional noecho)
288 "Move cursor to next instance of Mayan HAAB-DATE TZOLKIN-DATE combination. 288 "Move cursor to next instance of Mayan TZOLKIN-DATE HAAB-DATE combination.
289 Echo Mayan date if NOECHO is t." 289 Echo Mayan date unless NOECHO is non-nil."
290 (interactive (list (calendar-read-mayan-tzolkin-date) 290 (interactive (list (calendar-read-mayan-tzolkin-date)
291 (calendar-read-mayan-haab-date))) 291 (calendar-read-mayan-haab-date)))
292 (let ((date (calendar-mayan-tzolkin-haab-on-or-before 292 (let ((date (calendar-mayan-tzolkin-haab-on-or-before
293 tzolkin-date haab-date 293 tzolkin-date haab-date
294 (+ 18980 (calendar-absolute-from-gregorian 294 (+ 18980 (calendar-absolute-from-gregorian
370 (calendar-gregorian-from-absolute 370 (calendar-gregorian-from-absolute
371 (calendar-absolute-from-mayan-long-count date))) 371 (calendar-absolute-from-mayan-long-count date)))
372 (or noecho (calendar-print-mayan-date))) 372 (or noecho (calendar-print-mayan-date)))
373 373
374 (defun calendar-mayan-long-count-common-era (lc) 374 (defun calendar-mayan-long-count-common-era (lc)
375 "T if long count represents date in the Common Era." 375 "Return non-nil if long count LC represents a date in the Common Era."
376 (let ((base (calendar-mayan-long-count-from-absolute 1))) 376 (let ((base (calendar-mayan-long-count-from-absolute 1)))
377 (while (and (not (null base)) (= (car lc) (car base))) 377 (while (and (not (null base)) (= (car lc) (car base)))
378 (setq lc (cdr lc) 378 (setq lc (cdr lc)
379 base (cdr base))) 379 base (cdr base)))
380 (or (null lc) (> (car lc) (car base))))) 380 (or (null lc) (> (car lc) (car base)))))