Mercurial > emacs
comparison lisp/calendar/cal-mayan.el @ 88155:d7ddb3e565de
sync with trunk
author | Henrik Enberg <henrik.enberg@telia.com> |
---|---|
date | Mon, 16 Jan 2006 00:03:54 +0000 |
parents | 0d8b17d428b5 |
children |
comparison
equal
deleted
inserted
replaced
88154:8ce476d3ba36 | 88155:d7ddb3e565de |
---|---|
1 ;;; cal-mayan.el --- calendar functions for the Mayan calendars | 1 ;;; cal-mayan.el --- calendar functions for the Mayan calendars |
2 | 2 |
3 ;; Copyright (C) 1992, 1993, 1995, 1997 Free Software Foundation, Inc. | 3 ;; Copyright (C) 1992, 1993, 1995, 1997, 2001, 2002, 2003, 2004, 2005 |
4 ;; Free Software Foundation, Inc. | |
4 | 5 |
5 ;; Author: Stewart M. Clamen <clamen@cs.cmu.edu> | 6 ;; Author: Stewart M. Clamen <clamen@cs.cmu.edu> |
6 ;; Edward M. Reingold <reingold@cs.uiuc.edu> | 7 ;; Edward M. Reingold <reingold@cs.uiuc.edu> |
8 ;; Maintainer: Glenn Morris <rgm@gnu.org> | |
7 ;; Keywords: calendar | 9 ;; Keywords: calendar |
8 ;; Human-Keywords: Mayan calendar, Maya, calendar, diary | 10 ;; Human-Keywords: Mayan calendar, Maya, calendar, diary |
9 | 11 |
10 ;; This file is part of GNU Emacs. | 12 ;; This file is part of GNU Emacs. |
11 | 13 |
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 21 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
20 ;; GNU General Public License for more details. | 22 ;; GNU General Public License for more details. |
21 | 23 |
22 ;; You should have received a copy of the GNU General Public License | 24 ;; You should have received a copy of the GNU General Public License |
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the | 25 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 26 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
25 ;; Boston, MA 02111-1307, USA. | 27 ;; Boston, MA 02110-1301, USA. |
26 | 28 |
27 ;;; Commentary: | 29 ;;; Commentary: |
28 | 30 |
29 ;; This collection of functions implements the features of calendar.el and | 31 ;; This collection of functions implements the features of calendar.el and |
30 ;; diary.el that deal with the Mayan calendar. It was written jointly by | 32 ;; diary.el that deal with the Mayan calendar. It was written jointly by |
42 ;; Urbana, Illinois 61801 | 44 ;; Urbana, Illinois 61801 |
43 | 45 |
44 ;; Comments, improvements, and bug reports should be sent to Reingold. | 46 ;; Comments, improvements, and bug reports should be sent to Reingold. |
45 | 47 |
46 ;; Technical details of the Mayan calendrical calculations can be found in | 48 ;; Technical details of the Mayan calendrical calculations can be found in |
47 ;; ``Calendrical Calculations'' by Nachum Dershowitz and Edward M. Reingold, | 49 ;; ``Calendrical Calculations: The Millennium Edition'' by Edward M. Reingold |
48 ;; Cambridge University Press (1997), and in | 50 ;; and Nachum Dershowitz, Cambridge University Press (2001), and in |
49 ;; ``Calendrical Calculations, Part II: Three Historical Calendars'' | 51 ;; ``Calendrical Calculations, Part II: Three Historical Calendars'' |
50 ;; by E. M. Reingold, N. Dershowitz, and S. M. Clamen, | 52 ;; by E. M. Reingold, N. Dershowitz, and S. M. Clamen, |
51 ;; Software--Practice and Experience, Volume 23, Number 4 (April, 1993), | 53 ;; Software--Practice and Experience, Volume 23, Number 4 (April, 1993), |
52 ;; pages 383-404. | 54 ;; pages 383-404. |
53 | 55 |
54 ;;; Code: | 56 ;;; Code: |
57 | |
58 (defvar date) | |
55 | 59 |
56 (require 'calendar) | 60 (require 'calendar) |
57 | 61 |
58 (defconst calendar-mayan-days-before-absolute-zero 1137142 | 62 (defconst calendar-mayan-days-before-absolute-zero 1137142 |
59 "Number of days of the Mayan calendar epoch before absolute day 0. | 63 "Number of days of the Mayan calendar epoch before absolute day 0. |
254 "Haab kin (0-19): " | 258 "Haab kin (0-19): " |
255 '(lambda (x) (and (>= x 0) (< x 20))))) | 259 '(lambda (x) (and (>= x 0) (< x 20))))) |
256 (haab-month-list (append calendar-mayan-haab-month-name-array | 260 (haab-month-list (append calendar-mayan-haab-month-name-array |
257 (and (< haab-day 5) '("Uayeb")))) | 261 (and (< haab-day 5) '("Uayeb")))) |
258 (haab-month (cdr | 262 (haab-month (cdr |
259 (assoc-ignore-case | 263 (assoc-string |
260 (completing-read "Haab uinal: " | 264 (completing-read "Haab uinal: " |
261 (mapcar 'list haab-month-list) | 265 (mapcar 'list haab-month-list) |
262 nil t) | 266 nil t) |
263 (calendar-make-alist haab-month-list 1))))) | 267 (calendar-make-alist haab-month-list 1) t)))) |
264 (cons haab-day haab-month))) | 268 (cons haab-day haab-month))) |
265 | 269 |
266 (defun calendar-read-mayan-tzolkin-date () | 270 (defun calendar-read-mayan-tzolkin-date () |
267 "Prompt for a Mayan tzolkin date" | 271 "Prompt for a Mayan tzolkin date" |
268 (let* ((completion-ignore-case t) | 272 (let* ((completion-ignore-case t) |
269 (tzolkin-count (calendar-read | 273 (tzolkin-count (calendar-read |
270 "Tzolkin kin (1-13): " | 274 "Tzolkin kin (1-13): " |
271 '(lambda (x) (and (> x 0) (< x 14))))) | 275 '(lambda (x) (and (> x 0) (< x 14))))) |
272 (tzolkin-name-list (append calendar-mayan-tzolkin-names-array nil)) | 276 (tzolkin-name-list (append calendar-mayan-tzolkin-names-array nil)) |
273 (tzolkin-name (cdr | 277 (tzolkin-name (cdr |
274 (assoc-ignore-case | 278 (assoc-string |
275 (completing-read "Tzolkin uinal: " | 279 (completing-read "Tzolkin uinal: " |
276 (mapcar 'list tzolkin-name-list) | 280 (mapcar 'list tzolkin-name-list) |
277 nil t) | 281 nil t) |
278 (calendar-make-alist tzolkin-name-list 1))))) | 282 (calendar-make-alist tzolkin-name-list 1) t)))) |
279 (cons tzolkin-count tzolkin-name))) | 283 (cons tzolkin-count tzolkin-name))) |
280 | 284 |
281 (defun calendar-next-calendar-round-date | 285 (defun calendar-next-calendar-round-date |
282 (tzolkin-date haab-date &optional noecho) | 286 (tzolkin-date haab-date &optional noecho) |
283 "Move cursor to next instance of Mayan HAAB-DATE TZOLKIN-DATE combination. | 287 "Move cursor to next instance of Mayan HAAB-DATE TZOLKIN-DATE combination. |
374 "Show the Mayan long count, haab, and tzolkin dates as a diary entry." | 378 "Show the Mayan long count, haab, and tzolkin dates as a diary entry." |
375 (format "Mayan date: %s" (calendar-mayan-date-string date))) | 379 (format "Mayan date: %s" (calendar-mayan-date-string date))) |
376 | 380 |
377 (provide 'cal-mayan) | 381 (provide 'cal-mayan) |
378 | 382 |
383 ;;; arch-tag: 54f35144-cd0f-4873-935a-a60129de07df | |
379 ;;; cal-mayan.el ends here | 384 ;;; cal-mayan.el ends here |