aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/calendar/cal-mayan.el82
1 files changed, 53 insertions, 29 deletions
diff --git a/lisp/calendar/cal-mayan.el b/lisp/calendar/cal-mayan.el
index a66b11e2da2..176e32208c3 100644
--- a/lisp/calendar/cal-mayan.el
+++ b/lisp/calendar/cal-mayan.el
@@ -73,7 +73,7 @@ but some use 1137140. Using 1232041 gives you Spinden's correlation; using
73 "Convert MAYAN-LONG-COUNT into traditional written form." 73 "Convert MAYAN-LONG-COUNT into traditional written form."
74 (apply 'format (cons "%s.%s.%s.%s.%s" mayan-long-count))) 74 (apply 'format (cons "%s.%s.%s.%s.%s" mayan-long-count)))
75 75
76(defun calendar-string-to-mayan-long-count (str) 76(defun calendar-mayan-string-from-long-count (str)
77 "Given STR, a string of format \"%d.%d.%d.%d.%d\", return list of numbers." 77 "Given STR, a string of format \"%d.%d.%d.%d.%d\", return list of numbers."
78 (let ((end 0) 78 (let ((end 0)
79 rlc) 79 rlc)
@@ -127,13 +127,16 @@ but some use 1137140. Using 1232041 gives you Spinden's correlation; using
127 (calendar-mayan-haab-to-string haab)))) 127 (calendar-mayan-haab-to-string haab))))
128 128
129;;;###cal-autoload 129;;;###cal-autoload
130(defun calendar-print-mayan-date () 130(defun calendar-mayan-print-date ()
131 "Show the Mayan long count, tzolkin, and haab equivalents of date." 131 "Show the Mayan long count, tzolkin, and haab equivalents of date."
132 (interactive) 132 (interactive)
133 (message "Mayan date: %s" 133 (message "Mayan date: %s"
134 (calendar-mayan-date-string (calendar-cursor-to-date t)))) 134 (calendar-mayan-date-string (calendar-cursor-to-date t))))
135 135
136(defun calendar-read-mayan-haab-date () 136(define-obsolete-function-alias 'calendar-print-mayan-date
137 'calendar-mayan-print-date "23.1")
138
139(defun calendar-mayan-read-haab-date ()
137 "Prompt for a Mayan haab date." 140 "Prompt for a Mayan haab date."
138 (let* ((completion-ignore-case t) 141 (let* ((completion-ignore-case t)
139 (haab-day (calendar-read 142 (haab-day (calendar-read
@@ -149,7 +152,7 @@ but some use 1137140. Using 1232041 gives you Spinden's correlation; using
149 (calendar-make-alist haab-month-list 1) t)))) 152 (calendar-make-alist haab-month-list 1) t))))
150 (cons haab-day haab-month))) 153 (cons haab-day haab-month)))
151 154
152(defun calendar-read-mayan-tzolkin-date () 155(defun calendar-mayan-read-tzolkin-date ()
153 "Prompt for a Mayan tzolkin date." 156 "Prompt for a Mayan tzolkin date."
154 (let* ((completion-ignore-case t) 157 (let* ((completion-ignore-case t)
155 (tzolkin-count (calendar-read 158 (tzolkin-count (calendar-read
@@ -165,29 +168,35 @@ but some use 1137140. Using 1232041 gives you Spinden's correlation; using
165 (cons tzolkin-count tzolkin-name))) 168 (cons tzolkin-count tzolkin-name)))
166 169
167;;;###cal-autoload 170;;;###cal-autoload
168(defun calendar-next-haab-date (haab-date &optional noecho) 171(defun calendar-mayan-next-haab-date (haab-date &optional noecho)
169 "Move cursor to next instance of Mayan HAAB-DATE. 172 "Move cursor to next instance of Mayan HAAB-DATE.
170Echo Mayan date unless NOECHO is non-nil." 173Echo Mayan date unless NOECHO is non-nil."
171 (interactive (list (calendar-read-mayan-haab-date))) 174 (interactive (list (calendar-mayan-read-haab-date)))
172 (calendar-goto-date 175 (calendar-goto-date
173 (calendar-gregorian-from-absolute 176 (calendar-gregorian-from-absolute
174 (calendar-mayan-haab-on-or-before 177 (calendar-mayan-haab-on-or-before
175 haab-date 178 haab-date
176 (+ 365 179 (+ 365
177 (calendar-absolute-from-gregorian (calendar-cursor-to-date)))))) 180 (calendar-absolute-from-gregorian (calendar-cursor-to-date))))))
178 (or noecho (calendar-print-mayan-date))) 181 (or noecho (calendar-mayan-print-date)))
182
183(define-obsolete-function-alias 'calendar-next-haab-date
184 'calendar-mayan-next-haab-date "23.1")
179 185
180;;;###cal-autoload 186;;;###cal-autoload
181(defun calendar-previous-haab-date (haab-date &optional noecho) 187(defun calendar-mayan-previous-haab-date (haab-date &optional noecho)
182 "Move cursor to previous instance of Mayan HAAB-DATE. 188 "Move cursor to previous instance of Mayan HAAB-DATE.
183Echo Mayan date unless NOECHO is non-nil." 189Echo Mayan date unless NOECHO is non-nil."
184 (interactive (list (calendar-read-mayan-haab-date))) 190 (interactive (list (calendar-mayan-read-haab-date)))
185 (calendar-goto-date 191 (calendar-goto-date
186 (calendar-gregorian-from-absolute 192 (calendar-gregorian-from-absolute
187 (calendar-mayan-haab-on-or-before 193 (calendar-mayan-haab-on-or-before
188 haab-date 194 haab-date
189 (1- (calendar-absolute-from-gregorian (calendar-cursor-to-date)))))) 195 (1- (calendar-absolute-from-gregorian (calendar-cursor-to-date))))))
190 (or noecho (calendar-print-mayan-date))) 196 (or noecho (calendar-mayan-print-date)))
197
198(define-obsolete-function-alias 'calendar-previous-haab-date
199 'calendar-mayan-previous-haab-date "23.1")
191 200
192(defun calendar-mayan-haab-to-string (haab) 201(defun calendar-mayan-haab-to-string (haab)
193 "Convert Mayan HAAB date (a pair) into its traditional written form." 202 "Convert Mayan HAAB date (a pair) into its traditional written form."
@@ -227,29 +236,35 @@ Echo Mayan date unless NOECHO is non-nil."
227 260))) 236 260)))
228 237
229;;;###cal-autoload 238;;;###cal-autoload
230(defun calendar-next-tzolkin-date (tzolkin-date &optional noecho) 239(defun calendar-mayan-next-tzolkin-date (tzolkin-date &optional noecho)
231 "Move cursor to next instance of Mayan TZOLKIN-DATE. 240 "Move cursor to next instance of Mayan TZOLKIN-DATE.
232Echo Mayan date unless NOECHO is non-nil." 241Echo Mayan date unless NOECHO is non-nil."
233 (interactive (list (calendar-read-mayan-tzolkin-date))) 242 (interactive (list (calendar-mayan-read-tzolkin-date)))
234 (calendar-goto-date 243 (calendar-goto-date
235 (calendar-gregorian-from-absolute 244 (calendar-gregorian-from-absolute
236 (calendar-mayan-tzolkin-on-or-before 245 (calendar-mayan-tzolkin-on-or-before
237 tzolkin-date 246 tzolkin-date
238 (+ 260 247 (+ 260
239 (calendar-absolute-from-gregorian (calendar-cursor-to-date)))))) 248 (calendar-absolute-from-gregorian (calendar-cursor-to-date))))))
240 (or noecho (calendar-print-mayan-date))) 249 (or noecho (calendar-mayan-print-date)))
250
251(define-obsolete-function-alias 'calendar-next-tzolkin-date
252 'calendar-mayan-next-tzolkin-date "23.1")
241 253
242;;;###cal-autoload 254;;;###cal-autoload
243(defun calendar-previous-tzolkin-date (tzolkin-date &optional noecho) 255(defun calendar-mayan-previous-tzolkin-date (tzolkin-date &optional noecho)
244 "Move cursor to previous instance of Mayan TZOLKIN-DATE. 256 "Move cursor to previous instance of Mayan TZOLKIN-DATE.
245Echo Mayan date unless NOECHO is non-nil." 257Echo Mayan date unless NOECHO is non-nil."
246 (interactive (list (calendar-read-mayan-tzolkin-date))) 258 (interactive (list (calendar-mayan-read-tzolkin-date)))
247 (calendar-goto-date 259 (calendar-goto-date
248 (calendar-gregorian-from-absolute 260 (calendar-gregorian-from-absolute
249 (calendar-mayan-tzolkin-on-or-before 261 (calendar-mayan-tzolkin-on-or-before
250 tzolkin-date 262 tzolkin-date
251 (1- (calendar-absolute-from-gregorian (calendar-cursor-to-date)))))) 263 (1- (calendar-absolute-from-gregorian (calendar-cursor-to-date))))))
252 (or noecho (calendar-print-mayan-date))) 264 (or noecho (calendar-mayan-print-date)))
265
266(define-obsolete-function-alias 'calendar-previous-tzolkin-date
267 'calendar-mayan-previous-tzolkin-date "23.1")
253 268
254(defun calendar-mayan-tzolkin-to-string (tzolkin) 269(defun calendar-mayan-tzolkin-to-string (tzolkin)
255 "Convert Mayan TZOLKIN date (a pair) into its traditional written form." 270 "Convert Mayan TZOLKIN date (a pair) into its traditional written form."
@@ -278,12 +293,12 @@ Returns nil if such a tzolkin-haab combination is impossible."
278 nil))) 293 nil)))
279 294
280;;;###cal-autoload 295;;;###cal-autoload
281(defun calendar-next-calendar-round-date (tzolkin-date haab-date 296(defun calendar-mayan-next-round-date (tzolkin-date haab-date
282 &optional noecho) 297 &optional noecho)
283 "Move cursor to next instance of Mayan TZOLKIN-DATE HAAB-DATE combination. 298 "Move cursor to next instance of Mayan TZOLKIN-DATE HAAB-DATE combination.
284Echo Mayan date unless NOECHO is non-nil." 299Echo Mayan date unless NOECHO is non-nil."
285 (interactive (list (calendar-read-mayan-tzolkin-date) 300 (interactive (list (calendar-mayan-read-tzolkin-date)
286 (calendar-read-mayan-haab-date))) 301 (calendar-mayan-read-haab-date)))
287 (let ((date (calendar-mayan-tzolkin-haab-on-or-before 302 (let ((date (calendar-mayan-tzolkin-haab-on-or-before
288 tzolkin-date haab-date 303 tzolkin-date haab-date
289 (+ 18980 (calendar-absolute-from-gregorian 304 (+ 18980 (calendar-absolute-from-gregorian
@@ -293,15 +308,18 @@ Echo Mayan date unless NOECHO is non-nil."
293 (calendar-mayan-tzolkin-to-string tzolkin-date) 308 (calendar-mayan-tzolkin-to-string tzolkin-date)
294 (calendar-mayan-haab-to-string haab-date)) 309 (calendar-mayan-haab-to-string haab-date))
295 (calendar-goto-date (calendar-gregorian-from-absolute date)) 310 (calendar-goto-date (calendar-gregorian-from-absolute date))
296 (or noecho (calendar-print-mayan-date))))) 311 (or noecho (calendar-mayan-print-date)))))
312
313(define-obsolete-function-alias 'calendar-next-calendar-round-date
314 'calendar-mayan-next-round-date "23.1")
297 315
298;;;###cal-autoload 316;;;###cal-autoload
299(defun calendar-previous-calendar-round-date 317(defun calendar-mayan-previous-round-date
300 (tzolkin-date haab-date &optional noecho) 318 (tzolkin-date haab-date &optional noecho)
301 "Move to previous instance of Mayan TZOLKIN-DATE HAAB-DATE combination. 319 "Move to previous instance of Mayan TZOLKIN-DATE HAAB-DATE combination.
302Echo Mayan date unless NOECHO is non-nil." 320Echo Mayan date unless NOECHO is non-nil."
303 (interactive (list (calendar-read-mayan-tzolkin-date) 321 (interactive (list (calendar-mayan-read-tzolkin-date)
304 (calendar-read-mayan-haab-date))) 322 (calendar-mayan-read-haab-date)))
305 (let ((date (calendar-mayan-tzolkin-haab-on-or-before 323 (let ((date (calendar-mayan-tzolkin-haab-on-or-before
306 tzolkin-date haab-date 324 tzolkin-date haab-date
307 (1- (calendar-absolute-from-gregorian 325 (1- (calendar-absolute-from-gregorian
@@ -311,9 +329,12 @@ Echo Mayan date unless NOECHO is non-nil."
311 (calendar-mayan-tzolkin-to-string tzolkin-date) 329 (calendar-mayan-tzolkin-to-string tzolkin-date)
312 (calendar-mayan-haab-to-string haab-date)) 330 (calendar-mayan-haab-to-string haab-date))
313 (calendar-goto-date (calendar-gregorian-from-absolute date)) 331 (calendar-goto-date (calendar-gregorian-from-absolute date))
314 (or noecho (calendar-print-mayan-date))))) 332 (or noecho (calendar-mayan-print-date)))))
315 333
316(defun calendar-absolute-from-mayan-long-count (c) 334(define-obsolete-function-alias 'calendar-previous-calendar-round-date
335 'calendar-mayan-previous-round-date "23.1")
336
337(defun calendar-mayan-long-count-to-absolute (c)
317 "Compute the absolute date corresponding to the Mayan Long Count C. 338 "Compute the absolute date corresponding to the Mayan Long Count C.
318Long count is a list (baktun katun tun uinal kin)" 339Long count is a list (baktun katun tun uinal kin)"
319 (+ (* (nth 0 c) 144000) ; baktun 340 (+ (* (nth 0 c) 144000) ; baktun
@@ -333,13 +354,13 @@ Long count is a list (baktun katun tun uinal kin)"
333 (or (null lc) (> (car lc) (car base))))) 354 (or (null lc) (> (car lc) (car base)))))
334 355
335;;;###cal-autoload 356;;;###cal-autoload
336(defun calendar-goto-mayan-long-count-date (date &optional noecho) 357(defun calendar-mayan-goto-long-count-date (date &optional noecho)
337 "Move cursor to Mayan long count DATE. 358 "Move cursor to Mayan long count DATE.
338Echo Mayan date unless NOECHO is non-nil." 359Echo Mayan date unless NOECHO is non-nil."
339 (interactive 360 (interactive
340 (let (datum) 361 (let (datum)
341 (while (not (setq datum 362 (while (not (setq datum
342 (calendar-string-to-mayan-long-count 363 (calendar-mayan-string-from-long-count
343 (read-string 364 (read-string
344 "Mayan long count (baktun.katun.tun.uinal.kin): " 365 "Mayan long count (baktun.katun.tun.uinal.kin): "
345 (calendar-mayan-long-count-to-string 366 (calendar-mayan-long-count-to-string
@@ -351,8 +372,11 @@ Echo Mayan date unless NOECHO is non-nil."
351 datum)) 372 datum))
352 (calendar-goto-date 373 (calendar-goto-date
353 (calendar-gregorian-from-absolute 374 (calendar-gregorian-from-absolute
354 (calendar-absolute-from-mayan-long-count date))) 375 (calendar-mayan-long-count-to-absolute date)))
355 (or noecho (calendar-print-mayan-date))) 376 (or noecho (calendar-mayan-print-date)))
377
378(define-obsolete-function-alias 'calendar-goto-mayan-long-count-date
379 'calendar-mayan-goto-long-count-date "23.1")
356 380
357(defvar date) 381(defvar date)
358 382