diff options
| author | Glenn Morris | 2008-04-01 02:42:05 +0000 |
|---|---|---|
| committer | Glenn Morris | 2008-04-01 02:42:05 +0000 |
| commit | 4ab3241e9b5a1d5d9499d9ecf45e7a51b50620a4 (patch) | |
| tree | 1c338600c7bbbca82d978fc99830646d9b010c15 | |
| parent | 551c8f1ac7d87b6c3d746a9ef5db8c9537b8db7a (diff) | |
| download | emacs-4ab3241e9b5a1d5d9499d9ecf45e7a51b50620a4.tar.gz emacs-4ab3241e9b5a1d5d9499d9ecf45e7a51b50620a4.zip | |
(Commentary): Point to calendar.el.
(calendar-string-to-mayan-long-count, calendar-goto-mayan-long-count-date):
Simplify.
| -rw-r--r-- | lisp/calendar/cal-mayan.el | 64 |
1 files changed, 20 insertions, 44 deletions
diff --git a/lisp/calendar/cal-mayan.el b/lisp/calendar/cal-mayan.el index c36a82bc3e9..a66b11e2da2 100644 --- a/lisp/calendar/cal-mayan.el +++ b/lisp/calendar/cal-mayan.el | |||
| @@ -28,28 +28,7 @@ | |||
| 28 | 28 | ||
| 29 | ;;; Commentary: | 29 | ;;; Commentary: |
| 30 | 30 | ||
| 31 | ;; This collection of functions implements the features of calendar.el and | 31 | ;; See calendar.el. |
| 32 | ;; diary.el that deal with the Mayan calendar. It was written jointly by | ||
| 33 | |||
| 34 | ;; Stewart M. Clamen School of Computer Science | ||
| 35 | ;; clamen@cs.cmu.edu Carnegie Mellon University | ||
| 36 | ;; 5000 Forbes Avenue | ||
| 37 | ;; Pittsburgh, PA 15213 | ||
| 38 | |||
| 39 | ;; and | ||
| 40 | |||
| 41 | ;; Edward M. Reingold Department of Computer Science | ||
| 42 | ;; (217) 333-6733 University of Illinois at Urbana-Champaign | ||
| 43 | ;; reingold@cs.uiuc.edu 1304 West Springfield Avenue | ||
| 44 | ;; Urbana, Illinois 61801 | ||
| 45 | |||
| 46 | ;; Technical details of the Mayan calendrical calculations can be found in | ||
| 47 | ;; ``Calendrical Calculations: The Millennium Edition'' by Edward M. Reingold | ||
| 48 | ;; and Nachum Dershowitz, Cambridge University Press (2001), and in | ||
| 49 | ;; ``Calendrical Calculations, Part II: Three Historical Calendars'' | ||
| 50 | ;; by E. M. Reingold, N. Dershowitz, and S. M. Clamen, | ||
| 51 | ;; Software--Practice and Experience, Volume 23, Number 4 (April, 1993), | ||
| 52 | ;; pages 383-404. | ||
| 53 | 32 | ||
| 54 | ;;; Code: | 33 | ;;; Code: |
| 55 | 34 | ||
| @@ -96,20 +75,17 @@ but some use 1137140. Using 1232041 gives you Spinden's correlation; using | |||
| 96 | 75 | ||
| 97 | (defun calendar-string-to-mayan-long-count (str) | 76 | (defun calendar-string-to-mayan-long-count (str) |
| 98 | "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." |
| 99 | (let ((c (length str)) | 78 | (let ((end 0) |
| 100 | (cc 0) | ||
| 101 | rlc) | 79 | rlc) |
| 102 | (condition-case condition | 80 | (condition-case nil |
| 103 | (progn | 81 | (progn |
| 104 | (while (< cc c) | 82 | ;; cf split-string. |
| 105 | (let* ((start (string-match "[0-9]+" str cc)) | 83 | (while (string-match "[0-9]+" str end) |
| 106 | (end (match-end 0)) | 84 | (setq rlc (cons (string-to-number (match-string 0 str)) rlc) |
| 107 | (datum (read (substring str start end)))) | 85 | end (match-end 0))) |
| 108 | (setq rlc (cons datum rlc) | ||
| 109 | cc end))) | ||
| 110 | (unless (= (length rlc) 5) (signal 'invalid-read-syntax nil))) | 86 | (unless (= (length rlc) 5) (signal 'invalid-read-syntax nil))) |
| 111 | (invalid-read-syntax nil)) | 87 | (invalid-read-syntax nil)) |
| 112 | (reverse rlc))) | 88 | (nreverse rlc))) |
| 113 | 89 | ||
| 114 | (defun calendar-mayan-haab-from-absolute (date) | 90 | (defun calendar-mayan-haab-from-absolute (date) |
| 115 | "Convert absolute DATE into a Mayan haab date (a pair)." | 91 | "Convert absolute DATE into a Mayan haab date (a pair)." |
| @@ -361,18 +337,18 @@ Long count is a list (baktun katun tun uinal kin)" | |||
| 361 | "Move cursor to Mayan long count DATE. | 337 | "Move cursor to Mayan long count DATE. |
| 362 | Echo Mayan date unless NOECHO is non-nil." | 338 | Echo Mayan date unless NOECHO is non-nil." |
| 363 | (interactive | 339 | (interactive |
| 364 | (let (lc) | 340 | (let (datum) |
| 365 | (while (not lc) | 341 | (while (not (setq datum |
| 366 | (let ((datum | 342 | (calendar-string-to-mayan-long-count |
| 367 | (calendar-string-to-mayan-long-count | 343 | (read-string |
| 368 | (read-string "Mayan long count (baktun.katun.tun.uinal.kin): " | 344 | "Mayan long count (baktun.katun.tun.uinal.kin): " |
| 369 | (calendar-mayan-long-count-to-string | 345 | (calendar-mayan-long-count-to-string |
| 370 | (calendar-mayan-long-count-from-absolute | 346 | (calendar-mayan-long-count-from-absolute |
| 371 | (calendar-absolute-from-gregorian | 347 | (calendar-absolute-from-gregorian |
| 372 | (calendar-current-date)))))))) | 348 | (calendar-current-date)))))) |
| 373 | (if (calendar-mayan-long-count-common-era datum) | 349 | datum (if (calendar-mayan-long-count-common-era datum) |
| 374 | (setq lc datum)))) | 350 | (list datum))))) |
| 375 | (list lc))) | 351 | datum)) |
| 376 | (calendar-goto-date | 352 | (calendar-goto-date |
| 377 | (calendar-gregorian-from-absolute | 353 | (calendar-gregorian-from-absolute |
| 378 | (calendar-absolute-from-mayan-long-count date))) | 354 | (calendar-absolute-from-mayan-long-count date))) |