Mercurial > emacs
annotate lisp/calendar/cal-mayan.el @ 112407:3c76e72abd5d
Update configure
author | Miles Bader <miles@gnu.org> |
---|---|
date | Sat, 22 Jan 2011 11:46:10 +0900 |
parents | ef719132ddfa |
children |
rev | line source |
---|---|
38422
7a94f1c588c4
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
24185
diff
changeset
|
1 ;;; cal-mayan.el --- calendar functions for the Mayan calendars |
957 | 2 |
68721 | 3 ;; Copyright (C) 1992, 1993, 1995, 1997, 2001, 2002, 2003, 2004, 2005, |
112218
376148b31b5e
Add 2011 to FSF/AIST copyright years.
Glenn Morris <rgm@gnu.org>
parents:
106815
diff
changeset
|
4 ;; 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. |
957 | 5 |
6 ;; Author: Stewart M. Clamen <clamen@cs.cmu.edu> | |
92853 | 7 ;; Edward M. Reingold <reingold@cs.uiuc.edu> |
67465
a55ee709ec8d
Update copyright pending Emacs 22.
Glenn Morris <rgm@gnu.org>
parents:
65145
diff
changeset
|
8 ;; Maintainer: Glenn Morris <rgm@gnu.org> |
2247
2c7997f249eb
Add or correct keywords
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2106
diff
changeset
|
9 ;; Keywords: calendar |
2c7997f249eb
Add or correct keywords
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2106
diff
changeset
|
10 ;; Human-Keywords: Mayan calendar, Maya, calendar, diary |
110015
280c8ae2476d
Add "Package:" file headers to denote built-in packages.
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
11 ;; Package: calendar |
957 | 12 |
13 ;; This file is part of GNU Emacs. | |
14 | |
94653
e49abd957e81
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93784
diff
changeset
|
15 ;; GNU Emacs is free software: you can redistribute it and/or modify |
6736
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
6006
diff
changeset
|
16 ;; it under the terms of the GNU General Public License as published by |
94653
e49abd957e81
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93784
diff
changeset
|
17 ;; the Free Software Foundation, either version 3 of the License, or |
e49abd957e81
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93784
diff
changeset
|
18 ;; (at your option) any later version. |
957 | 19 |
6736
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
6006
diff
changeset
|
20 ;; GNU Emacs is distributed in the hope that it will be useful, |
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
6006
diff
changeset
|
21 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
6006
diff
changeset
|
22 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
6006
diff
changeset
|
23 ;; GNU General Public License for more details. |
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
6006
diff
changeset
|
24 |
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
6006
diff
changeset
|
25 ;; You should have received a copy of the GNU General Public License |
94653
e49abd957e81
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93784
diff
changeset
|
26 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
957 | 27 |
28 ;;; Commentary: | |
29 | |
93484
0c5143f2417b
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93001
diff
changeset
|
30 ;; See calendar.el. |
957 | 31 |
32 ;;; Code: | |
33 | |
34 (require 'calendar) | |
35 | |
19972
fe92da0414ac
(calendar-mayan-days-before-absolute-zero): Change
Karl Heuer <kwzh@gnu.org>
parents:
14169
diff
changeset
|
36 (defconst calendar-mayan-days-before-absolute-zero 1137142 |
3869
037e012d04b0
* cal-mayan.el (calendar-mayan-days-before-absolute-zero,
Jim Blandy <jimb@redhat.com>
parents:
2945
diff
changeset
|
37 "Number of days of the Mayan calendar epoch before absolute day 0. |
19972
fe92da0414ac
(calendar-mayan-days-before-absolute-zero): Change
Karl Heuer <kwzh@gnu.org>
parents:
14169
diff
changeset
|
38 This is the Goodman-Martinez-Thompson correlation used by almost all experts, |
fe92da0414ac
(calendar-mayan-days-before-absolute-zero): Change
Karl Heuer <kwzh@gnu.org>
parents:
14169
diff
changeset
|
39 but some use 1137140. Using 1232041 gives you Spinden's correlation; using |
fe92da0414ac
(calendar-mayan-days-before-absolute-zero): Change
Karl Heuer <kwzh@gnu.org>
parents:
14169
diff
changeset
|
40 1142840 gives you Hochleitner's correlation.") |
957 | 41 |
42 (defconst calendar-mayan-haab-at-epoch '(8 . 18) | |
43 "Mayan haab date at the epoch.") | |
44 | |
45 (defconst calendar-mayan-haab-month-name-array | |
46 ["Pop" "Uo" "Zip" "Zotz" "Tzec" "Xul" "Yaxkin" "Mol" "Chen" "Yax" | |
92920
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
47 "Zac" "Ceh" "Mac" "Kankin" "Muan" "Pax" "Kayab" "Cumku"] |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
48 "Names of the Mayan haab months.") |
957 | 49 |
50 (defconst calendar-mayan-tzolkin-at-epoch '(4 . 20) | |
51 "Mayan tzolkin date at the epoch.") | |
52 | |
53 (defconst calendar-mayan-tzolkin-names-array | |
54 ["Imix" "Ik" "Akbal" "Kan" "Chicchan" "Cimi" "Manik" "Lamat" "Muluc" "Oc" | |
92920
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
55 "Chuen" "Eb" "Ben" "Ix" "Men" "Cib" "Caban" "Etznab" "Cauac" "Ahau"] |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
56 "Names of the Mayan tzolkin months.") |
957 | 57 |
58 (defun calendar-mayan-long-count-from-absolute (date) | |
59 "Compute the Mayan long count corresponding to the absolute DATE." | |
92920
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
60 (let* ((long-count (+ date calendar-mayan-days-before-absolute-zero)) |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
61 (baktun (/ long-count 144000)) |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
62 (remainder (% long-count 144000)) |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
63 (katun (/ remainder 7200)) |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
64 (remainder (% remainder 7200)) |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
65 (tun (/ remainder 360)) |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
66 (remainder (% remainder 360)) |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
67 (uinal (/ remainder 20)) |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
68 (kin (% remainder 20))) |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
69 (list baktun katun tun uinal kin))) |
957 | 70 |
71 (defun calendar-mayan-long-count-to-string (mayan-long-count) | |
72 "Convert MAYAN-LONG-COUNT into traditional written form." | |
73 (apply 'format (cons "%s.%s.%s.%s.%s" mayan-long-count))) | |
74 | |
93645
8b04f0b12fa3
(calendar-mayan-string-from-long-count): Rename
Glenn Morris <rgm@gnu.org>
parents:
93484
diff
changeset
|
75 (defun calendar-mayan-string-from-long-count (str) |
92636
f565309f0cab
(calendar-string-to-mayan-long-count)
Glenn Morris <rgm@gnu.org>
parents:
92607
diff
changeset
|
76 "Given STR, a string of format \"%d.%d.%d.%d.%d\", return list of numbers." |
93484
0c5143f2417b
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93001
diff
changeset
|
77 (let ((end 0) |
92920
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
78 rlc) |
93484
0c5143f2417b
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93001
diff
changeset
|
79 (condition-case nil |
957 | 80 (progn |
93484
0c5143f2417b
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93001
diff
changeset
|
81 ;; cf split-string. |
0c5143f2417b
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93001
diff
changeset
|
82 (while (string-match "[0-9]+" str end) |
0c5143f2417b
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93001
diff
changeset
|
83 (setq rlc (cons (string-to-number (match-string 0 str)) rlc) |
0c5143f2417b
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93001
diff
changeset
|
84 end (match-end 0))) |
92920
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
85 (unless (= (length rlc) 5) (signal 'invalid-read-syntax nil))) |
957 | 86 (invalid-read-syntax nil)) |
93484
0c5143f2417b
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93001
diff
changeset
|
87 (nreverse rlc))) |
957 | 88 |
89 (defun calendar-mayan-haab-from-absolute (date) | |
90 "Convert absolute DATE into a Mayan haab date (a pair)." | |
91 (let* ((long-count (+ date calendar-mayan-days-before-absolute-zero)) | |
92 (day-of-haab | |
93 (% (+ long-count | |
94 (car calendar-mayan-haab-at-epoch) | |
95 (* 20 (1- (cdr calendar-mayan-haab-at-epoch)))) | |
96 365)) | |
97 (day (% day-of-haab 20)) | |
98 (month (1+ (/ day-of-haab 20)))) | |
99 (cons day month))) | |
100 | |
101 (defun calendar-mayan-haab-difference (date1 date2) | |
3869
037e012d04b0
* cal-mayan.el (calendar-mayan-days-before-absolute-zero,
Jim Blandy <jimb@redhat.com>
parents:
2945
diff
changeset
|
102 "Number of days from Mayan haab DATE1 to next occurrence of haab date DATE2." |
4521
2308b366bfc8
(calendar-/, calendar-%): Remove, since floor and mod
Paul Eggert <eggert@twinsun.com>
parents:
3869
diff
changeset
|
103 (mod (+ (* 20 (- (cdr date2) (cdr date1))) |
92853 | 104 (- (car date2) (car date1))) |
4521
2308b366bfc8
(calendar-/, calendar-%): Remove, since floor and mod
Paul Eggert <eggert@twinsun.com>
parents:
3869
diff
changeset
|
105 365)) |
957 | 106 |
107 (defun calendar-mayan-haab-on-or-before (haab-date date) | |
108 "Absolute date of latest HAAB-DATE on or before absolute DATE." | |
2106
f90250f69413
* cal-mayan.el (calendar-mayan-haab-on-or-before,
Jim Blandy <jimb@redhat.com>
parents:
1353
diff
changeset
|
109 (- date |
f90250f69413
* cal-mayan.el (calendar-mayan-haab-on-or-before,
Jim Blandy <jimb@redhat.com>
parents:
1353
diff
changeset
|
110 (% (- date |
92853 | 111 (calendar-mayan-haab-difference |
112 (calendar-mayan-haab-from-absolute 0) haab-date)) | |
113 365))) | |
957 | 114 |
92835
5e8d6a369c62
(generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents:
92636
diff
changeset
|
115 ;;;###cal-autoload |
92920
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
116 (defun calendar-mayan-date-string (&optional date) |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
117 "String of Mayan date of Gregorian DATE; default today." |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
118 (let* ((d (calendar-absolute-from-gregorian |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
119 (or date (calendar-current-date)))) |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
120 (tzolkin (calendar-mayan-tzolkin-from-absolute d)) |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
121 (haab (calendar-mayan-haab-from-absolute d)) |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
122 (long-count (calendar-mayan-long-count-from-absolute d))) |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
123 (format "Long count = %s; tzolkin = %s; haab = %s" |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
124 (calendar-mayan-long-count-to-string long-count) |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
125 (calendar-mayan-tzolkin-to-string tzolkin) |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
126 (calendar-mayan-haab-to-string haab)))) |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
127 |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
128 ;;;###cal-autoload |
93645
8b04f0b12fa3
(calendar-mayan-string-from-long-count): Rename
Glenn Morris <rgm@gnu.org>
parents:
93484
diff
changeset
|
129 (defun calendar-mayan-print-date () |
92920
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
130 "Show the Mayan long count, tzolkin, and haab equivalents of date." |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
131 (interactive) |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
132 (message "Mayan date: %s" |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
133 (calendar-mayan-date-string (calendar-cursor-to-date t)))) |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
134 |
93645
8b04f0b12fa3
(calendar-mayan-string-from-long-count): Rename
Glenn Morris <rgm@gnu.org>
parents:
93484
diff
changeset
|
135 (define-obsolete-function-alias 'calendar-print-mayan-date |
8b04f0b12fa3
(calendar-mayan-string-from-long-count): Rename
Glenn Morris <rgm@gnu.org>
parents:
93484
diff
changeset
|
136 'calendar-mayan-print-date "23.1") |
8b04f0b12fa3
(calendar-mayan-string-from-long-count): Rename
Glenn Morris <rgm@gnu.org>
parents:
93484
diff
changeset
|
137 |
8b04f0b12fa3
(calendar-mayan-string-from-long-count): Rename
Glenn Morris <rgm@gnu.org>
parents:
93484
diff
changeset
|
138 (defun calendar-mayan-read-haab-date () |
92920
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
139 "Prompt for a Mayan haab date." |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
140 (let* ((completion-ignore-case t) |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
141 (haab-day (calendar-read |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
142 "Haab kin (0-19): " |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
143 (lambda (x) (and (>= x 0) (< x 20))))) |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
144 (haab-month-list (append calendar-mayan-haab-month-name-array |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
145 (and (< haab-day 5) '("Uayeb")))) |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
146 (haab-month (cdr |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
147 (assoc-string |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
148 (completing-read "Haab uinal: " |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
149 (mapcar 'list haab-month-list) |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
150 nil t) |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
151 (calendar-make-alist haab-month-list 1) t)))) |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
152 (cons haab-day haab-month))) |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
153 |
93645
8b04f0b12fa3
(calendar-mayan-string-from-long-count): Rename
Glenn Morris <rgm@gnu.org>
parents:
93484
diff
changeset
|
154 (defun calendar-mayan-read-tzolkin-date () |
92920
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
155 "Prompt for a Mayan tzolkin date." |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
156 (let* ((completion-ignore-case t) |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
157 (tzolkin-count (calendar-read |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
158 "Tzolkin kin (1-13): " |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
159 (lambda (x) (and (> x 0) (< x 14))))) |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
160 (tzolkin-name-list (append calendar-mayan-tzolkin-names-array nil)) |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
161 (tzolkin-name (cdr |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
162 (assoc-string |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
163 (completing-read "Tzolkin uinal: " |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
164 (mapcar 'list tzolkin-name-list) |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
165 nil t) |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
166 (calendar-make-alist tzolkin-name-list 1) t)))) |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
167 (cons tzolkin-count tzolkin-name))) |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
168 |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
169 ;;;###cal-autoload |
93645
8b04f0b12fa3
(calendar-mayan-string-from-long-count): Rename
Glenn Morris <rgm@gnu.org>
parents:
93484
diff
changeset
|
170 (defun calendar-mayan-next-haab-date (haab-date &optional noecho) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
38422
diff
changeset
|
171 "Move cursor to next instance of Mayan HAAB-DATE. |
92920
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
172 Echo Mayan date unless NOECHO is non-nil." |
93645
8b04f0b12fa3
(calendar-mayan-string-from-long-count): Rename
Glenn Morris <rgm@gnu.org>
parents:
93484
diff
changeset
|
173 (interactive (list (calendar-mayan-read-haab-date))) |
957 | 174 (calendar-goto-date |
175 (calendar-gregorian-from-absolute | |
176 (calendar-mayan-haab-on-or-before | |
177 haab-date | |
178 (+ 365 | |
179 (calendar-absolute-from-gregorian (calendar-cursor-to-date)))))) | |
93645
8b04f0b12fa3
(calendar-mayan-string-from-long-count): Rename
Glenn Morris <rgm@gnu.org>
parents:
93484
diff
changeset
|
180 (or noecho (calendar-mayan-print-date))) |
8b04f0b12fa3
(calendar-mayan-string-from-long-count): Rename
Glenn Morris <rgm@gnu.org>
parents:
93484
diff
changeset
|
181 |
8b04f0b12fa3
(calendar-mayan-string-from-long-count): Rename
Glenn Morris <rgm@gnu.org>
parents:
93484
diff
changeset
|
182 (define-obsolete-function-alias 'calendar-next-haab-date |
8b04f0b12fa3
(calendar-mayan-string-from-long-count): Rename
Glenn Morris <rgm@gnu.org>
parents:
93484
diff
changeset
|
183 'calendar-mayan-next-haab-date "23.1") |
957 | 184 |
92835
5e8d6a369c62
(generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents:
92636
diff
changeset
|
185 ;;;###cal-autoload |
93645
8b04f0b12fa3
(calendar-mayan-string-from-long-count): Rename
Glenn Morris <rgm@gnu.org>
parents:
93484
diff
changeset
|
186 (defun calendar-mayan-previous-haab-date (haab-date &optional noecho) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
38422
diff
changeset
|
187 "Move cursor to previous instance of Mayan HAAB-DATE. |
92920
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
188 Echo Mayan date unless NOECHO is non-nil." |
93645
8b04f0b12fa3
(calendar-mayan-string-from-long-count): Rename
Glenn Morris <rgm@gnu.org>
parents:
93484
diff
changeset
|
189 (interactive (list (calendar-mayan-read-haab-date))) |
957 | 190 (calendar-goto-date |
191 (calendar-gregorian-from-absolute | |
192 (calendar-mayan-haab-on-or-before | |
193 haab-date | |
194 (1- (calendar-absolute-from-gregorian (calendar-cursor-to-date)))))) | |
93645
8b04f0b12fa3
(calendar-mayan-string-from-long-count): Rename
Glenn Morris <rgm@gnu.org>
parents:
93484
diff
changeset
|
195 (or noecho (calendar-mayan-print-date))) |
8b04f0b12fa3
(calendar-mayan-string-from-long-count): Rename
Glenn Morris <rgm@gnu.org>
parents:
93484
diff
changeset
|
196 |
8b04f0b12fa3
(calendar-mayan-string-from-long-count): Rename
Glenn Morris <rgm@gnu.org>
parents:
93484
diff
changeset
|
197 (define-obsolete-function-alias 'calendar-previous-haab-date |
8b04f0b12fa3
(calendar-mayan-string-from-long-count): Rename
Glenn Morris <rgm@gnu.org>
parents:
93484
diff
changeset
|
198 'calendar-mayan-previous-haab-date "23.1") |
957 | 199 |
200 (defun calendar-mayan-haab-to-string (haab) | |
92636
f565309f0cab
(calendar-string-to-mayan-long-count)
Glenn Morris <rgm@gnu.org>
parents:
92607
diff
changeset
|
201 "Convert Mayan HAAB date (a pair) into its traditional written form." |
93001
6c85b8971fe3
(calendar-mayan-haab-to-string): Simplify.
Glenn Morris <rgm@gnu.org>
parents:
92920
diff
changeset
|
202 (let ((month (cdr haab))) |
6c85b8971fe3
(calendar-mayan-haab-to-string): Simplify.
Glenn Morris <rgm@gnu.org>
parents:
92920
diff
changeset
|
203 (format "%d %s" (car haab) ; day |
6c85b8971fe3
(calendar-mayan-haab-to-string): Simplify.
Glenn Morris <rgm@gnu.org>
parents:
92920
diff
changeset
|
204 ;; 19th month consists of 5 special days |
6c85b8971fe3
(calendar-mayan-haab-to-string): Simplify.
Glenn Morris <rgm@gnu.org>
parents:
92920
diff
changeset
|
205 (if (= month 19) "Uayeb" |
92853 | 206 (aref calendar-mayan-haab-month-name-array (1- month)))))) |
957 | 207 |
208 (defun calendar-mayan-tzolkin-from-absolute (date) | |
209 "Convert absolute DATE into a Mayan tzolkin date (a pair)." | |
210 (let* ((long-count (+ date calendar-mayan-days-before-absolute-zero)) | |
93001
6c85b8971fe3
(calendar-mayan-haab-to-string): Simplify.
Glenn Morris <rgm@gnu.org>
parents:
92920
diff
changeset
|
211 ;; Remainder on division by 13,20 with 13,20 instead of zero. |
6c85b8971fe3
(calendar-mayan-haab-to-string): Simplify.
Glenn Morris <rgm@gnu.org>
parents:
92920
diff
changeset
|
212 (day (1+ (mod |
6c85b8971fe3
(calendar-mayan-haab-to-string): Simplify.
Glenn Morris <rgm@gnu.org>
parents:
92920
diff
changeset
|
213 (1- (+ long-count (car calendar-mayan-tzolkin-at-epoch))) |
6c85b8971fe3
(calendar-mayan-haab-to-string): Simplify.
Glenn Morris <rgm@gnu.org>
parents:
92920
diff
changeset
|
214 13))) |
6c85b8971fe3
(calendar-mayan-haab-to-string): Simplify.
Glenn Morris <rgm@gnu.org>
parents:
92920
diff
changeset
|
215 (name (1+ (mod |
6c85b8971fe3
(calendar-mayan-haab-to-string): Simplify.
Glenn Morris <rgm@gnu.org>
parents:
92920
diff
changeset
|
216 (1- (+ long-count (cdr calendar-mayan-tzolkin-at-epoch))) |
6c85b8971fe3
(calendar-mayan-haab-to-string): Simplify.
Glenn Morris <rgm@gnu.org>
parents:
92920
diff
changeset
|
217 20)))) |
957 | 218 (cons day name))) |
219 | |
220 (defun calendar-mayan-tzolkin-difference (date1 date2) | |
3869
037e012d04b0
* cal-mayan.el (calendar-mayan-days-before-absolute-zero,
Jim Blandy <jimb@redhat.com>
parents:
2945
diff
changeset
|
221 "Number of days from Mayan tzolkin DATE1 to next occurrence of tzolkin DATE2." |
957 | 222 (let ((number-difference (- (car date2) (car date1))) |
223 (name-difference (- (cdr date2) (cdr date1)))) | |
4521
2308b366bfc8
(calendar-/, calendar-%): Remove, since floor and mod
Paul Eggert <eggert@twinsun.com>
parents:
3869
diff
changeset
|
224 (mod (+ number-difference |
92853 | 225 (* 13 (mod (* 3 (- number-difference name-difference)) |
226 20))) | |
227 260))) | |
957 | 228 |
229 (defun calendar-mayan-tzolkin-on-or-before (tzolkin-date date) | |
230 "Absolute date of latest TZOLKIN-DATE on or before absolute DATE." | |
2106
f90250f69413
* cal-mayan.el (calendar-mayan-haab-on-or-before,
Jim Blandy <jimb@redhat.com>
parents:
1353
diff
changeset
|
231 (- date |
f90250f69413
* cal-mayan.el (calendar-mayan-haab-on-or-before,
Jim Blandy <jimb@redhat.com>
parents:
1353
diff
changeset
|
232 (% (- date (calendar-mayan-tzolkin-difference |
92853 | 233 (calendar-mayan-tzolkin-from-absolute 0) |
234 tzolkin-date)) | |
235 260))) | |
957 | 236 |
92835
5e8d6a369c62
(generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents:
92636
diff
changeset
|
237 ;;;###cal-autoload |
93645
8b04f0b12fa3
(calendar-mayan-string-from-long-count): Rename
Glenn Morris <rgm@gnu.org>
parents:
93484
diff
changeset
|
238 (defun calendar-mayan-next-tzolkin-date (tzolkin-date &optional noecho) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
38422
diff
changeset
|
239 "Move cursor to next instance of Mayan TZOLKIN-DATE. |
92920
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
240 Echo Mayan date unless NOECHO is non-nil." |
93645
8b04f0b12fa3
(calendar-mayan-string-from-long-count): Rename
Glenn Morris <rgm@gnu.org>
parents:
93484
diff
changeset
|
241 (interactive (list (calendar-mayan-read-tzolkin-date))) |
957 | 242 (calendar-goto-date |
243 (calendar-gregorian-from-absolute | |
244 (calendar-mayan-tzolkin-on-or-before | |
245 tzolkin-date | |
246 (+ 260 | |
247 (calendar-absolute-from-gregorian (calendar-cursor-to-date)))))) | |
93645
8b04f0b12fa3
(calendar-mayan-string-from-long-count): Rename
Glenn Morris <rgm@gnu.org>
parents:
93484
diff
changeset
|
248 (or noecho (calendar-mayan-print-date))) |
8b04f0b12fa3
(calendar-mayan-string-from-long-count): Rename
Glenn Morris <rgm@gnu.org>
parents:
93484
diff
changeset
|
249 |
8b04f0b12fa3
(calendar-mayan-string-from-long-count): Rename
Glenn Morris <rgm@gnu.org>
parents:
93484
diff
changeset
|
250 (define-obsolete-function-alias 'calendar-next-tzolkin-date |
8b04f0b12fa3
(calendar-mayan-string-from-long-count): Rename
Glenn Morris <rgm@gnu.org>
parents:
93484
diff
changeset
|
251 'calendar-mayan-next-tzolkin-date "23.1") |
957 | 252 |
92835
5e8d6a369c62
(generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents:
92636
diff
changeset
|
253 ;;;###cal-autoload |
93645
8b04f0b12fa3
(calendar-mayan-string-from-long-count): Rename
Glenn Morris <rgm@gnu.org>
parents:
93484
diff
changeset
|
254 (defun calendar-mayan-previous-tzolkin-date (tzolkin-date &optional noecho) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
38422
diff
changeset
|
255 "Move cursor to previous instance of Mayan TZOLKIN-DATE. |
92920
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
256 Echo Mayan date unless NOECHO is non-nil." |
93645
8b04f0b12fa3
(calendar-mayan-string-from-long-count): Rename
Glenn Morris <rgm@gnu.org>
parents:
93484
diff
changeset
|
257 (interactive (list (calendar-mayan-read-tzolkin-date))) |
957 | 258 (calendar-goto-date |
259 (calendar-gregorian-from-absolute | |
260 (calendar-mayan-tzolkin-on-or-before | |
261 tzolkin-date | |
262 (1- (calendar-absolute-from-gregorian (calendar-cursor-to-date)))))) | |
93645
8b04f0b12fa3
(calendar-mayan-string-from-long-count): Rename
Glenn Morris <rgm@gnu.org>
parents:
93484
diff
changeset
|
263 (or noecho (calendar-mayan-print-date))) |
8b04f0b12fa3
(calendar-mayan-string-from-long-count): Rename
Glenn Morris <rgm@gnu.org>
parents:
93484
diff
changeset
|
264 |
8b04f0b12fa3
(calendar-mayan-string-from-long-count): Rename
Glenn Morris <rgm@gnu.org>
parents:
93484
diff
changeset
|
265 (define-obsolete-function-alias 'calendar-previous-tzolkin-date |
8b04f0b12fa3
(calendar-mayan-string-from-long-count): Rename
Glenn Morris <rgm@gnu.org>
parents:
93484
diff
changeset
|
266 'calendar-mayan-previous-tzolkin-date "23.1") |
957 | 267 |
268 (defun calendar-mayan-tzolkin-to-string (tzolkin) | |
92636
f565309f0cab
(calendar-string-to-mayan-long-count)
Glenn Morris <rgm@gnu.org>
parents:
92607
diff
changeset
|
269 "Convert Mayan TZOLKIN date (a pair) into its traditional written form." |
957 | 270 (format "%d %s" |
271 (car tzolkin) | |
272 (aref calendar-mayan-tzolkin-names-array (1- (cdr tzolkin))))) | |
273 | |
274 (defun calendar-mayan-tzolkin-haab-on-or-before (tzolkin-date haab-date date) | |
3869
037e012d04b0
* cal-mayan.el (calendar-mayan-days-before-absolute-zero,
Jim Blandy <jimb@redhat.com>
parents:
2945
diff
changeset
|
275 "Absolute date that is Mayan TZOLKIN-DATE and HAAB-DATE. |
037e012d04b0
* cal-mayan.el (calendar-mayan-days-before-absolute-zero,
Jim Blandy <jimb@redhat.com>
parents:
2945
diff
changeset
|
276 Latest such date on or before DATE. |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
38422
diff
changeset
|
277 Returns nil if such a tzolkin-haab combination is impossible." |
957 | 278 (let* ((haab-difference |
279 (calendar-mayan-haab-difference | |
280 (calendar-mayan-haab-from-absolute 0) | |
281 haab-date)) | |
282 (tzolkin-difference | |
283 (calendar-mayan-tzolkin-difference | |
284 (calendar-mayan-tzolkin-from-absolute 0) | |
285 tzolkin-date)) | |
286 (difference (- tzolkin-difference haab-difference))) | |
92920
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
287 (if (zerop (% difference 5)) |
957 | 288 (- date |
4521
2308b366bfc8
(calendar-/, calendar-%): Remove, since floor and mod
Paul Eggert <eggert@twinsun.com>
parents:
3869
diff
changeset
|
289 (mod (- date |
92853 | 290 (+ haab-difference (* 365 difference))) |
291 18980)) | |
957 | 292 nil))) |
293 | |
92835
5e8d6a369c62
(generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents:
92636
diff
changeset
|
294 ;;;###cal-autoload |
93645
8b04f0b12fa3
(calendar-mayan-string-from-long-count): Rename
Glenn Morris <rgm@gnu.org>
parents:
93484
diff
changeset
|
295 (defun calendar-mayan-next-round-date (tzolkin-date haab-date |
92636
f565309f0cab
(calendar-string-to-mayan-long-count)
Glenn Morris <rgm@gnu.org>
parents:
92607
diff
changeset
|
296 &optional noecho) |
f565309f0cab
(calendar-string-to-mayan-long-count)
Glenn Morris <rgm@gnu.org>
parents:
92607
diff
changeset
|
297 "Move cursor to next instance of Mayan TZOLKIN-DATE HAAB-DATE combination. |
f565309f0cab
(calendar-string-to-mayan-long-count)
Glenn Morris <rgm@gnu.org>
parents:
92607
diff
changeset
|
298 Echo Mayan date unless NOECHO is non-nil." |
93645
8b04f0b12fa3
(calendar-mayan-string-from-long-count): Rename
Glenn Morris <rgm@gnu.org>
parents:
93484
diff
changeset
|
299 (interactive (list (calendar-mayan-read-tzolkin-date) |
8b04f0b12fa3
(calendar-mayan-string-from-long-count): Rename
Glenn Morris <rgm@gnu.org>
parents:
93484
diff
changeset
|
300 (calendar-mayan-read-haab-date))) |
957 | 301 (let ((date (calendar-mayan-tzolkin-haab-on-or-before |
302 tzolkin-date haab-date | |
303 (+ 18980 (calendar-absolute-from-gregorian | |
304 (calendar-cursor-to-date)))))) | |
305 (if (not date) | |
306 (error "%s, %s does not exist in the Mayan calendar round" | |
307 (calendar-mayan-tzolkin-to-string tzolkin-date) | |
308 (calendar-mayan-haab-to-string haab-date)) | |
309 (calendar-goto-date (calendar-gregorian-from-absolute date)) | |
93645
8b04f0b12fa3
(calendar-mayan-string-from-long-count): Rename
Glenn Morris <rgm@gnu.org>
parents:
93484
diff
changeset
|
310 (or noecho (calendar-mayan-print-date))))) |
8b04f0b12fa3
(calendar-mayan-string-from-long-count): Rename
Glenn Morris <rgm@gnu.org>
parents:
93484
diff
changeset
|
311 |
8b04f0b12fa3
(calendar-mayan-string-from-long-count): Rename
Glenn Morris <rgm@gnu.org>
parents:
93484
diff
changeset
|
312 (define-obsolete-function-alias 'calendar-next-calendar-round-date |
8b04f0b12fa3
(calendar-mayan-string-from-long-count): Rename
Glenn Morris <rgm@gnu.org>
parents:
93484
diff
changeset
|
313 'calendar-mayan-next-round-date "23.1") |
957 | 314 |
92835
5e8d6a369c62
(generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents:
92636
diff
changeset
|
315 ;;;###cal-autoload |
93645
8b04f0b12fa3
(calendar-mayan-string-from-long-count): Rename
Glenn Morris <rgm@gnu.org>
parents:
93484
diff
changeset
|
316 (defun calendar-mayan-previous-round-date |
957 | 317 (tzolkin-date haab-date &optional noecho) |
13672
bb7e5d35f83b
(calendar-next-calendar-round-date, calendar-previous-calendar-round-date):
Paul Eggert <eggert@twinsun.com>
parents:
13048
diff
changeset
|
318 "Move to previous instance of Mayan TZOLKIN-DATE HAAB-DATE combination. |
92920
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
319 Echo Mayan date unless NOECHO is non-nil." |
93645
8b04f0b12fa3
(calendar-mayan-string-from-long-count): Rename
Glenn Morris <rgm@gnu.org>
parents:
93484
diff
changeset
|
320 (interactive (list (calendar-mayan-read-tzolkin-date) |
8b04f0b12fa3
(calendar-mayan-string-from-long-count): Rename
Glenn Morris <rgm@gnu.org>
parents:
93484
diff
changeset
|
321 (calendar-mayan-read-haab-date))) |
957 | 322 (let ((date (calendar-mayan-tzolkin-haab-on-or-before |
323 tzolkin-date haab-date | |
324 (1- (calendar-absolute-from-gregorian | |
325 (calendar-cursor-to-date)))))) | |
326 (if (not date) | |
327 (error "%s, %s does not exist in the Mayan calendar round" | |
328 (calendar-mayan-tzolkin-to-string tzolkin-date) | |
329 (calendar-mayan-haab-to-string haab-date)) | |
330 (calendar-goto-date (calendar-gregorian-from-absolute date)) | |
93645
8b04f0b12fa3
(calendar-mayan-string-from-long-count): Rename
Glenn Morris <rgm@gnu.org>
parents:
93484
diff
changeset
|
331 (or noecho (calendar-mayan-print-date))))) |
957 | 332 |
93645
8b04f0b12fa3
(calendar-mayan-string-from-long-count): Rename
Glenn Morris <rgm@gnu.org>
parents:
93484
diff
changeset
|
333 (define-obsolete-function-alias 'calendar-previous-calendar-round-date |
8b04f0b12fa3
(calendar-mayan-string-from-long-count): Rename
Glenn Morris <rgm@gnu.org>
parents:
93484
diff
changeset
|
334 'calendar-mayan-previous-round-date "23.1") |
8b04f0b12fa3
(calendar-mayan-string-from-long-count): Rename
Glenn Morris <rgm@gnu.org>
parents:
93484
diff
changeset
|
335 |
8b04f0b12fa3
(calendar-mayan-string-from-long-count): Rename
Glenn Morris <rgm@gnu.org>
parents:
93484
diff
changeset
|
336 (defun calendar-mayan-long-count-to-absolute (c) |
3869
037e012d04b0
* cal-mayan.el (calendar-mayan-days-before-absolute-zero,
Jim Blandy <jimb@redhat.com>
parents:
2945
diff
changeset
|
337 "Compute the absolute date corresponding to the Mayan Long Count C. |
037e012d04b0
* cal-mayan.el (calendar-mayan-days-before-absolute-zero,
Jim Blandy <jimb@redhat.com>
parents:
2945
diff
changeset
|
338 Long count is a list (baktun katun tun uinal kin)" |
92853 | 339 (+ (* (nth 0 c) 144000) ; baktun |
340 (* (nth 1 c) 7200) ; katun | |
341 (* (nth 2 c) 360) ; tun | |
342 (* (nth 3 c) 20) ; uinal | |
343 (nth 4 c) ; kin (days) | |
92920
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
344 ;; Days before absolute date 0. |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
345 (- calendar-mayan-days-before-absolute-zero))) |
957 | 346 |
93646
a1ece6da90e8
(calendar-mayan-long-count-to-absolute): Keep old name as alias.
Glenn Morris <rgm@gnu.org>
parents:
93645
diff
changeset
|
347 (define-obsolete-function-alias 'calendar-absolute-from-mayan-long-count |
a1ece6da90e8
(calendar-mayan-long-count-to-absolute): Keep old name as alias.
Glenn Morris <rgm@gnu.org>
parents:
93645
diff
changeset
|
348 'calendar-mayan-long-count-to-absolute "23.1") |
a1ece6da90e8
(calendar-mayan-long-count-to-absolute): Keep old name as alias.
Glenn Morris <rgm@gnu.org>
parents:
93645
diff
changeset
|
349 |
92920
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
350 (defun calendar-mayan-long-count-common-era (lc) |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
351 "Return non-nil if long count LC represents a date in the Common Era." |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
352 (let ((base (calendar-mayan-long-count-from-absolute 1))) |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
353 (while (and base (= (car lc) (car base))) |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
354 (setq lc (cdr lc) |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
355 base (cdr base))) |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
356 (or (null lc) (> (car lc) (car base))))) |
957 | 357 |
92835
5e8d6a369c62
(generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents:
92636
diff
changeset
|
358 ;;;###cal-autoload |
93645
8b04f0b12fa3
(calendar-mayan-string-from-long-count): Rename
Glenn Morris <rgm@gnu.org>
parents:
93484
diff
changeset
|
359 (defun calendar-mayan-goto-long-count-date (date &optional noecho) |
92920
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
360 "Move cursor to Mayan long count DATE. |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
361 Echo Mayan date unless NOECHO is non-nil." |
957 | 362 (interactive |
93484
0c5143f2417b
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93001
diff
changeset
|
363 (let (datum) |
0c5143f2417b
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93001
diff
changeset
|
364 (while (not (setq datum |
93645
8b04f0b12fa3
(calendar-mayan-string-from-long-count): Rename
Glenn Morris <rgm@gnu.org>
parents:
93484
diff
changeset
|
365 (calendar-mayan-string-from-long-count |
93484
0c5143f2417b
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93001
diff
changeset
|
366 (read-string |
0c5143f2417b
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93001
diff
changeset
|
367 "Mayan long count (baktun.katun.tun.uinal.kin): " |
0c5143f2417b
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93001
diff
changeset
|
368 (calendar-mayan-long-count-to-string |
0c5143f2417b
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93001
diff
changeset
|
369 (calendar-mayan-long-count-from-absolute |
0c5143f2417b
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93001
diff
changeset
|
370 (calendar-absolute-from-gregorian |
0c5143f2417b
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93001
diff
changeset
|
371 (calendar-current-date)))))) |
0c5143f2417b
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93001
diff
changeset
|
372 datum (if (calendar-mayan-long-count-common-era datum) |
0c5143f2417b
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93001
diff
changeset
|
373 (list datum))))) |
0c5143f2417b
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93001
diff
changeset
|
374 datum)) |
957 | 375 (calendar-goto-date |
376 (calendar-gregorian-from-absolute | |
93645
8b04f0b12fa3
(calendar-mayan-string-from-long-count): Rename
Glenn Morris <rgm@gnu.org>
parents:
93484
diff
changeset
|
377 (calendar-mayan-long-count-to-absolute date))) |
8b04f0b12fa3
(calendar-mayan-string-from-long-count): Rename
Glenn Morris <rgm@gnu.org>
parents:
93484
diff
changeset
|
378 (or noecho (calendar-mayan-print-date))) |
8b04f0b12fa3
(calendar-mayan-string-from-long-count): Rename
Glenn Morris <rgm@gnu.org>
parents:
93484
diff
changeset
|
379 |
8b04f0b12fa3
(calendar-mayan-string-from-long-count): Rename
Glenn Morris <rgm@gnu.org>
parents:
93484
diff
changeset
|
380 (define-obsolete-function-alias 'calendar-goto-mayan-long-count-date |
8b04f0b12fa3
(calendar-mayan-string-from-long-count): Rename
Glenn Morris <rgm@gnu.org>
parents:
93484
diff
changeset
|
381 'calendar-mayan-goto-long-count-date "23.1") |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
38422
diff
changeset
|
382 |
92607 | 383 (defvar date) |
384 | |
93784 | 385 ;; To be called from diary-list-sexp-entries, where DATE is bound. |
92835
5e8d6a369c62
(generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents:
92636
diff
changeset
|
386 ;;;###diary-autoload |
957 | 387 (defun diary-mayan-date () |
388 "Show the Mayan long count, haab, and tzolkin dates as a diary entry." | |
5700
6620aa507202
(calendar-mayan-date-string): New function.
Richard M. Stallman <rms@gnu.org>
parents:
4521
diff
changeset
|
389 (format "Mayan date: %s" (calendar-mayan-date-string date))) |
957 | 390 |
391 (provide 'cal-mayan) | |
392 | |
393 ;;; cal-mayan.el ends here |