Mercurial > emacs
comparison lisp/calendar/cal-mayan.el @ 93645:8b04f0b12fa3
(calendar-mayan-string-from-long-count): Rename
calendar-string-to-mayan-long-count. Update callers.
(calendar-mayan-print-date): Rename calendar-print-mayan-date.
Update callers, keep old name as alias.
(calendar-mayan-read-haab-date): Rename calendar-read-mayan-haab-date.
Update callers.
(calendar-mayan-read-tzolkin-date): Rename calendar-read-mayan-tzolkin-date.
Update callers.
(calendar-mayan-next-haab-date): Rename calendar-next-haab-date.
Keep old name as alias.
(calendar-mayan-previous-haab-date): Rename calendar-previous-haab-date.
Keep old name as alias.
(calendar-mayan-next-tzolkin-date): Rename calendar-next-tzolkin-date.
Keep old name as alias.
(calendar-mayan-previous-tzolkin-date): Rename calendar-previous-tzolkin-date.
Keep old name as alias.
(calendar-mayan-next-round-date): Rename calendar-next-calendar-round-date.
Keep old name as alias.
(calendar-mayan-previous-round-date): Rename
calendar-previous-calendar-round-date. Keep old name as alias.
(calendar-mayan-long-count-to-absolute): Rename
calendar-absolute-from-mayan-long-count. Keep old name as alias.
(calendar-mayan-goto-long-count-date): Rename
calendar-goto-mayan-long-count-date. Keep old name as alias.
author | Glenn Morris <rgm@gnu.org> |
---|---|
date | Fri, 04 Apr 2008 07:27:24 +0000 |
parents | 0c5143f2417b |
children | a1ece6da90e8 |
comparison
equal
deleted
inserted
replaced
93644:05a344ce267f | 93645:8b04f0b12fa3 |
---|---|
71 | 71 |
72 (defun calendar-mayan-long-count-to-string (mayan-long-count) | 72 (defun calendar-mayan-long-count-to-string (mayan-long-count) |
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) |
80 (condition-case nil | 80 (condition-case nil |
81 (progn | 81 (progn |
125 (calendar-mayan-long-count-to-string long-count) | 125 (calendar-mayan-long-count-to-string long-count) |
126 (calendar-mayan-tzolkin-to-string tzolkin) | 126 (calendar-mayan-tzolkin-to-string tzolkin) |
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 |
140 "Haab kin (0-19): " | 143 "Haab kin (0-19): " |
141 (lambda (x) (and (>= x 0) (< x 20))))) | 144 (lambda (x) (and (>= x 0) (< x 20))))) |
147 (mapcar 'list haab-month-list) | 150 (mapcar 'list haab-month-list) |
148 nil t) | 151 nil t) |
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 |
156 "Tzolkin kin (1-13): " | 159 "Tzolkin kin (1-13): " |
157 (lambda (x) (and (> x 0) (< x 14))))) | 160 (lambda (x) (and (> x 0) (< x 14))))) |
163 nil t) | 166 nil t) |
164 (calendar-make-alist tzolkin-name-list 1) t)))) | 167 (calendar-make-alist tzolkin-name-list 1) t)))) |
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. |
170 Echo Mayan date unless NOECHO is non-nil." | 173 Echo 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))) |
179 | 182 |
180 ;;;###cal-autoload | 183 (define-obsolete-function-alias 'calendar-next-haab-date |
181 (defun calendar-previous-haab-date (haab-date &optional noecho) | 184 'calendar-mayan-next-haab-date "23.1") |
185 | |
186 ;;;###cal-autoload | |
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. |
183 Echo Mayan date unless NOECHO is non-nil." | 189 Echo 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." |
194 (let ((month (cdr haab))) | 203 (let ((month (cdr haab))) |
195 (format "%d %s" (car haab) ; day | 204 (format "%d %s" (car haab) ; day |
225 (calendar-mayan-tzolkin-from-absolute 0) | 234 (calendar-mayan-tzolkin-from-absolute 0) |
226 tzolkin-date)) | 235 tzolkin-date)) |
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. |
232 Echo Mayan date unless NOECHO is non-nil." | 241 Echo 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))) |
241 | 250 |
242 ;;;###cal-autoload | 251 (define-obsolete-function-alias 'calendar-next-tzolkin-date |
243 (defun calendar-previous-tzolkin-date (tzolkin-date &optional noecho) | 252 'calendar-mayan-next-tzolkin-date "23.1") |
253 | |
254 ;;;###cal-autoload | |
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. |
245 Echo Mayan date unless NOECHO is non-nil." | 257 Echo 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." |
256 (format "%d %s" | 271 (format "%d %s" |
257 (car tzolkin) | 272 (car tzolkin) |
276 (+ haab-difference (* 365 difference))) | 291 (+ haab-difference (* 365 difference))) |
277 18980)) | 292 18980)) |
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. |
284 Echo Mayan date unless NOECHO is non-nil." | 299 Echo 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 |
290 (calendar-cursor-to-date)))))) | 305 (calendar-cursor-to-date)))))) |
291 (if (not date) | 306 (if (not date) |
292 (error "%s, %s does not exist in the Mayan calendar round" | 307 (error "%s, %s does not exist in the Mayan calendar round" |
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))))) |
297 | 312 |
298 ;;;###cal-autoload | 313 (define-obsolete-function-alias 'calendar-next-calendar-round-date |
299 (defun calendar-previous-calendar-round-date | 314 'calendar-mayan-next-round-date "23.1") |
315 | |
316 ;;;###cal-autoload | |
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. |
302 Echo Mayan date unless NOECHO is non-nil." | 320 Echo 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 |
308 (calendar-cursor-to-date)))))) | 326 (calendar-cursor-to-date)))))) |
309 (if (not date) | 327 (if (not date) |
310 (error "%s, %s does not exist in the Mayan calendar round" | 328 (error "%s, %s does not exist in the Mayan calendar round" |
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. |
318 Long count is a list (baktun katun tun uinal kin)" | 339 Long count is a list (baktun katun tun uinal kin)" |
319 (+ (* (nth 0 c) 144000) ; baktun | 340 (+ (* (nth 0 c) 144000) ; baktun |
320 (* (nth 1 c) 7200) ; katun | 341 (* (nth 1 c) 7200) ; katun |
321 (* (nth 2 c) 360) ; tun | 342 (* (nth 2 c) 360) ; tun |
331 (setq lc (cdr lc) | 352 (setq lc (cdr lc) |
332 base (cdr base))) | 353 base (cdr base))) |
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. |
338 Echo Mayan date unless NOECHO is non-nil." | 359 Echo 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 |
346 (calendar-mayan-long-count-from-absolute | 367 (calendar-mayan-long-count-from-absolute |
347 (calendar-absolute-from-gregorian | 368 (calendar-absolute-from-gregorian |
349 datum (if (calendar-mayan-long-count-common-era datum) | 370 datum (if (calendar-mayan-long-count-common-era datum) |
350 (list datum))))) | 371 (list datum))))) |
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 |
359 ;; To be called from list-sexp-diary-entries, where DATE is bound. | 383 ;; To be called from list-sexp-diary-entries, where DATE is bound. |
360 ;;;###diary-autoload | 384 ;;;###diary-autoload |