Mercurial > emacs
annotate lisp/calendar/cal-mayan.el @ 94272:d861bedec991
*** empty log message ***
author | Nick Roberts <nickrob@snap.net.nz> |
---|---|
date | Wed, 23 Apr 2008 02:48:40 +0000 |
parents | 4ad805f0f03f |
children | e49abd957e81 |
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, |
79703 | 4 ;; 2006, 2007, 2008 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 |
957 | 11 |
12 ;; This file is part of GNU Emacs. | |
13 | |
6736
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
6006
diff
changeset
|
14 ;; GNU Emacs is free software; you can redistribute it and/or modify |
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
6006
diff
changeset
|
15 ;; it under the terms of the GNU General Public License as published by |
78216
93e11478c954
Switch license to GPLv3 or later.
Glenn Morris <rgm@gnu.org>
parents:
77279
diff
changeset
|
16 ;; the Free Software Foundation; either version 3, or (at your option) |
6736
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
6006
diff
changeset
|
17 ;; any later version. |
957 | 18 |
6736
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
6006
diff
changeset
|
19 ;; 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
|
20 ;; 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
|
21 ;; 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
|
22 ;; 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
|
23 |
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
6006
diff
changeset
|
24 ;; You should have received a copy of the GNU General Public License |
14169 | 25 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
64085 | 26 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
27 ;; Boston, MA 02110-1301, USA. | |
957 | 28 |
29 ;;; Commentary: | |
30 | |
93484
0c5143f2417b
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93001
diff
changeset
|
31 ;; See calendar.el. |
957 | 32 |
33 ;;; Code: | |
34 | |
35 (require 'calendar) | |
36 | |
19972
fe92da0414ac
(calendar-mayan-days-before-absolute-zero): Change
Karl Heuer <kwzh@gnu.org>
parents:
14169
diff
changeset
|
37 (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
|
38 "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
|
39 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
|
40 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
|
41 1142840 gives you Hochleitner's correlation.") |
957 | 42 |
43 (defconst calendar-mayan-haab-at-epoch '(8 . 18) | |
44 "Mayan haab date at the epoch.") | |
45 | |
46 (defconst calendar-mayan-haab-month-name-array | |
47 ["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
|
48 "Zac" "Ceh" "Mac" "Kankin" "Muan" "Pax" "Kayab" "Cumku"] |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
49 "Names of the Mayan haab months.") |
957 | 50 |
51 (defconst calendar-mayan-tzolkin-at-epoch '(4 . 20) | |
52 "Mayan tzolkin date at the epoch.") | |
53 | |
54 (defconst calendar-mayan-tzolkin-names-array | |
55 ["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
|
56 "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
|
57 "Names of the Mayan tzolkin months.") |
957 | 58 |
59 (defun calendar-mayan-long-count-from-absolute (date) | |
60 "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
|
61 (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
|
62 (baktun (/ long-count 144000)) |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
63 (remainder (% long-count 144000)) |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
64 (katun (/ remainder 7200)) |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
65 (remainder (% remainder 7200)) |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
66 (tun (/ remainder 360)) |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
67 (remainder (% remainder 360)) |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
68 (uinal (/ remainder 20)) |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
69 (kin (% remainder 20))) |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
70 (list baktun katun tun uinal kin))) |
957 | 71 |
72 (defun calendar-mayan-long-count-to-string (mayan-long-count) | |
73 "Convert MAYAN-LONG-COUNT into traditional written form." | |
74 (apply 'format (cons "%s.%s.%s.%s.%s" mayan-long-count))) | |
75 | |
93645
8b04f0b12fa3
(calendar-mayan-string-from-long-count): Rename
Glenn Morris <rgm@gnu.org>
parents:
93484
diff
changeset
|
76 (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
|
77 "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
|
78 (let ((end 0) |
92920
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
79 rlc) |
93484
0c5143f2417b
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93001
diff
changeset
|
80 (condition-case nil |
957 | 81 (progn |
93484
0c5143f2417b
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93001
diff
changeset
|
82 ;; cf split-string. |
0c5143f2417b
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93001
diff
changeset
|
83 (while (string-match "[0-9]+" str end) |
0c5143f2417b
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93001
diff
changeset
|
84 (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
|
85 end (match-end 0))) |
92920
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
86 (unless (= (length rlc) 5) (signal 'invalid-read-syntax nil))) |
957 | 87 (invalid-read-syntax nil)) |
93484
0c5143f2417b
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93001
diff
changeset
|
88 (nreverse rlc))) |
957 | 89 |
90 (defun calendar-mayan-haab-from-absolute (date) | |
91 "Convert absolute DATE into a Mayan haab date (a pair)." | |
92 (let* ((long-count (+ date calendar-mayan-days-before-absolute-zero)) | |
93 (day-of-haab | |
94 (% (+ long-count | |
95 (car calendar-mayan-haab-at-epoch) | |
96 (* 20 (1- (cdr calendar-mayan-haab-at-epoch)))) | |
97 365)) | |
98 (day (% day-of-haab 20)) | |
99 (month (1+ (/ day-of-haab 20)))) | |
100 (cons day month))) | |
101 | |
102 (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
|
103 "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
|
104 (mod (+ (* 20 (- (cdr date2) (cdr date1))) |
92853 | 105 (- (car date2) (car date1))) |
4521
2308b366bfc8
(calendar-/, calendar-%): Remove, since floor and mod
Paul Eggert <eggert@twinsun.com>
parents:
3869
diff
changeset
|
106 365)) |
957 | 107 |
108 (defun calendar-mayan-haab-on-or-before (haab-date date) | |
109 "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
|
110 (- date |
f90250f69413
* cal-mayan.el (calendar-mayan-haab-on-or-before,
Jim Blandy <jimb@redhat.com>
parents:
1353
diff
changeset
|
111 (% (- date |
92853 | 112 (calendar-mayan-haab-difference |
113 (calendar-mayan-haab-from-absolute 0) haab-date)) | |
114 365))) | |
957 | 115 |
92835
5e8d6a369c62
(generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents:
92636
diff
changeset
|
116 ;;;###cal-autoload |
92920
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
117 (defun calendar-mayan-date-string (&optional date) |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
118 "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
|
119 (let* ((d (calendar-absolute-from-gregorian |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
120 (or date (calendar-current-date)))) |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
121 (tzolkin (calendar-mayan-tzolkin-from-absolute d)) |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
122 (haab (calendar-mayan-haab-from-absolute d)) |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
123 (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
|
124 (format "Long count = %s; tzolkin = %s; haab = %s" |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
125 (calendar-mayan-long-count-to-string long-count) |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
126 (calendar-mayan-tzolkin-to-string tzolkin) |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
127 (calendar-mayan-haab-to-string haab)))) |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
128 |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
129 ;;;###cal-autoload |
93645
8b04f0b12fa3
(calendar-mayan-string-from-long-count): Rename
Glenn Morris <rgm@gnu.org>
parents:
93484
diff
changeset
|
130 (defun calendar-mayan-print-date () |
92920
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
131 "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
|
132 (interactive) |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
133 (message "Mayan date: %s" |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
134 (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
|
135 |
93645
8b04f0b12fa3
(calendar-mayan-string-from-long-count): Rename
Glenn Morris <rgm@gnu.org>
parents:
93484
diff
changeset
|
136 (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
|
137 'calendar-mayan-print-date "23.1") |
8b04f0b12fa3
(calendar-mayan-string-from-long-count): Rename
Glenn Morris <rgm@gnu.org>
parents:
93484
diff
changeset
|
138 |
8b04f0b12fa3
(calendar-mayan-string-from-long-count): Rename
Glenn Morris <rgm@gnu.org>
parents:
93484
diff
changeset
|
139 (defun calendar-mayan-read-haab-date () |
92920
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
140 "Prompt for a Mayan haab date." |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
141 (let* ((completion-ignore-case t) |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
142 (haab-day (calendar-read |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
143 "Haab kin (0-19): " |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
144 (lambda (x) (and (>= x 0) (< x 20))))) |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
145 (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
|
146 (and (< haab-day 5) '("Uayeb")))) |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
147 (haab-month (cdr |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
148 (assoc-string |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
149 (completing-read "Haab uinal: " |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
150 (mapcar 'list haab-month-list) |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
151 nil t) |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
152 (calendar-make-alist haab-month-list 1) t)))) |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
153 (cons haab-day haab-month))) |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
154 |
93645
8b04f0b12fa3
(calendar-mayan-string-from-long-count): Rename
Glenn Morris <rgm@gnu.org>
parents:
93484
diff
changeset
|
155 (defun calendar-mayan-read-tzolkin-date () |
92920
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
156 "Prompt for a Mayan tzolkin date." |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
157 (let* ((completion-ignore-case t) |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
158 (tzolkin-count (calendar-read |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
159 "Tzolkin kin (1-13): " |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
160 (lambda (x) (and (> x 0) (< x 14))))) |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
161 (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
|
162 (tzolkin-name (cdr |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
163 (assoc-string |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
164 (completing-read "Tzolkin uinal: " |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
165 (mapcar 'list tzolkin-name-list) |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
166 nil t) |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
167 (calendar-make-alist tzolkin-name-list 1) t)))) |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
168 (cons tzolkin-count tzolkin-name))) |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
169 |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
170 ;;;###cal-autoload |
93645
8b04f0b12fa3
(calendar-mayan-string-from-long-count): Rename
Glenn Morris <rgm@gnu.org>
parents:
93484
diff
changeset
|
171 (defun calendar-mayan-next-haab-date (haab-date &optional noecho) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
38422
diff
changeset
|
172 "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
|
173 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
|
174 (interactive (list (calendar-mayan-read-haab-date))) |
957 | 175 (calendar-goto-date |
176 (calendar-gregorian-from-absolute | |
177 (calendar-mayan-haab-on-or-before | |
178 haab-date | |
179 (+ 365 | |
180 (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
|
181 (or noecho (calendar-mayan-print-date))) |
8b04f0b12fa3
(calendar-mayan-string-from-long-count): Rename
Glenn Morris <rgm@gnu.org>
parents:
93484
diff
changeset
|
182 |
8b04f0b12fa3
(calendar-mayan-string-from-long-count): Rename
Glenn Morris <rgm@gnu.org>
parents:
93484
diff
changeset
|
183 (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
|
184 'calendar-mayan-next-haab-date "23.1") |
957 | 185 |
92835
5e8d6a369c62
(generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents:
92636
diff
changeset
|
186 ;;;###cal-autoload |
93645
8b04f0b12fa3
(calendar-mayan-string-from-long-count): Rename
Glenn Morris <rgm@gnu.org>
parents:
93484
diff
changeset
|
187 (defun calendar-mayan-previous-haab-date (haab-date &optional noecho) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
38422
diff
changeset
|
188 "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
|
189 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
|
190 (interactive (list (calendar-mayan-read-haab-date))) |
957 | 191 (calendar-goto-date |
192 (calendar-gregorian-from-absolute | |
193 (calendar-mayan-haab-on-or-before | |
194 haab-date | |
195 (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
|
196 (or noecho (calendar-mayan-print-date))) |
8b04f0b12fa3
(calendar-mayan-string-from-long-count): Rename
Glenn Morris <rgm@gnu.org>
parents:
93484
diff
changeset
|
197 |
8b04f0b12fa3
(calendar-mayan-string-from-long-count): Rename
Glenn Morris <rgm@gnu.org>
parents:
93484
diff
changeset
|
198 (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
|
199 'calendar-mayan-previous-haab-date "23.1") |
957 | 200 |
201 (defun calendar-mayan-haab-to-string (haab) | |
92636
f565309f0cab
(calendar-string-to-mayan-long-count)
Glenn Morris <rgm@gnu.org>
parents:
92607
diff
changeset
|
202 "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
|
203 (let ((month (cdr haab))) |
6c85b8971fe3
(calendar-mayan-haab-to-string): Simplify.
Glenn Morris <rgm@gnu.org>
parents:
92920
diff
changeset
|
204 (format "%d %s" (car haab) ; day |
6c85b8971fe3
(calendar-mayan-haab-to-string): Simplify.
Glenn Morris <rgm@gnu.org>
parents:
92920
diff
changeset
|
205 ;; 19th month consists of 5 special days |
6c85b8971fe3
(calendar-mayan-haab-to-string): Simplify.
Glenn Morris <rgm@gnu.org>
parents:
92920
diff
changeset
|
206 (if (= month 19) "Uayeb" |
92853 | 207 (aref calendar-mayan-haab-month-name-array (1- month)))))) |
957 | 208 |
209 (defun calendar-mayan-tzolkin-from-absolute (date) | |
210 "Convert absolute DATE into a Mayan tzolkin date (a pair)." | |
211 (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
|
212 ;; 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
|
213 (day (1+ (mod |
6c85b8971fe3
(calendar-mayan-haab-to-string): Simplify.
Glenn Morris <rgm@gnu.org>
parents:
92920
diff
changeset
|
214 (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
|
215 13))) |
6c85b8971fe3
(calendar-mayan-haab-to-string): Simplify.
Glenn Morris <rgm@gnu.org>
parents:
92920
diff
changeset
|
216 (name (1+ (mod |
6c85b8971fe3
(calendar-mayan-haab-to-string): Simplify.
Glenn Morris <rgm@gnu.org>
parents:
92920
diff
changeset
|
217 (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
|
218 20)))) |
957 | 219 (cons day name))) |
220 | |
221 (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
|
222 "Number of days from Mayan tzolkin DATE1 to next occurrence of tzolkin DATE2." |
957 | 223 (let ((number-difference (- (car date2) (car date1))) |
224 (name-difference (- (cdr date2) (cdr date1)))) | |
4521
2308b366bfc8
(calendar-/, calendar-%): Remove, since floor and mod
Paul Eggert <eggert@twinsun.com>
parents:
3869
diff
changeset
|
225 (mod (+ number-difference |
92853 | 226 (* 13 (mod (* 3 (- number-difference name-difference)) |
227 20))) | |
228 260))) | |
957 | 229 |
230 (defun calendar-mayan-tzolkin-on-or-before (tzolkin-date date) | |
231 "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
|
232 (- date |
f90250f69413
* cal-mayan.el (calendar-mayan-haab-on-or-before,
Jim Blandy <jimb@redhat.com>
parents:
1353
diff
changeset
|
233 (% (- date (calendar-mayan-tzolkin-difference |
92853 | 234 (calendar-mayan-tzolkin-from-absolute 0) |
235 tzolkin-date)) | |
236 260))) | |
957 | 237 |
92835
5e8d6a369c62
(generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents:
92636
diff
changeset
|
238 ;;;###cal-autoload |
93645
8b04f0b12fa3
(calendar-mayan-string-from-long-count): Rename
Glenn Morris <rgm@gnu.org>
parents:
93484
diff
changeset
|
239 (defun calendar-mayan-next-tzolkin-date (tzolkin-date &optional noecho) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
38422
diff
changeset
|
240 "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
|
241 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
|
242 (interactive (list (calendar-mayan-read-tzolkin-date))) |
957 | 243 (calendar-goto-date |
244 (calendar-gregorian-from-absolute | |
245 (calendar-mayan-tzolkin-on-or-before | |
246 tzolkin-date | |
247 (+ 260 | |
248 (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
|
249 (or noecho (calendar-mayan-print-date))) |
8b04f0b12fa3
(calendar-mayan-string-from-long-count): Rename
Glenn Morris <rgm@gnu.org>
parents:
93484
diff
changeset
|
250 |
8b04f0b12fa3
(calendar-mayan-string-from-long-count): Rename
Glenn Morris <rgm@gnu.org>
parents:
93484
diff
changeset
|
251 (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
|
252 'calendar-mayan-next-tzolkin-date "23.1") |
957 | 253 |
92835
5e8d6a369c62
(generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents:
92636
diff
changeset
|
254 ;;;###cal-autoload |
93645
8b04f0b12fa3
(calendar-mayan-string-from-long-count): Rename
Glenn Morris <rgm@gnu.org>
parents:
93484
diff
changeset
|
255 (defun calendar-mayan-previous-tzolkin-date (tzolkin-date &optional noecho) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
38422
diff
changeset
|
256 "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
|
257 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
|
258 (interactive (list (calendar-mayan-read-tzolkin-date))) |
957 | 259 (calendar-goto-date |
260 (calendar-gregorian-from-absolute | |
261 (calendar-mayan-tzolkin-on-or-before | |
262 tzolkin-date | |
263 (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
|
264 (or noecho (calendar-mayan-print-date))) |
8b04f0b12fa3
(calendar-mayan-string-from-long-count): Rename
Glenn Morris <rgm@gnu.org>
parents:
93484
diff
changeset
|
265 |
8b04f0b12fa3
(calendar-mayan-string-from-long-count): Rename
Glenn Morris <rgm@gnu.org>
parents:
93484
diff
changeset
|
266 (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
|
267 'calendar-mayan-previous-tzolkin-date "23.1") |
957 | 268 |
269 (defun calendar-mayan-tzolkin-to-string (tzolkin) | |
92636
f565309f0cab
(calendar-string-to-mayan-long-count)
Glenn Morris <rgm@gnu.org>
parents:
92607
diff
changeset
|
270 "Convert Mayan TZOLKIN date (a pair) into its traditional written form." |
957 | 271 (format "%d %s" |
272 (car tzolkin) | |
273 (aref calendar-mayan-tzolkin-names-array (1- (cdr tzolkin))))) | |
274 | |
275 (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
|
276 "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
|
277 Latest such date on or before DATE. |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
38422
diff
changeset
|
278 Returns nil if such a tzolkin-haab combination is impossible." |
957 | 279 (let* ((haab-difference |
280 (calendar-mayan-haab-difference | |
281 (calendar-mayan-haab-from-absolute 0) | |
282 haab-date)) | |
283 (tzolkin-difference | |
284 (calendar-mayan-tzolkin-difference | |
285 (calendar-mayan-tzolkin-from-absolute 0) | |
286 tzolkin-date)) | |
287 (difference (- tzolkin-difference haab-difference))) | |
92920
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
288 (if (zerop (% difference 5)) |
957 | 289 (- date |
4521
2308b366bfc8
(calendar-/, calendar-%): Remove, since floor and mod
Paul Eggert <eggert@twinsun.com>
parents:
3869
diff
changeset
|
290 (mod (- date |
92853 | 291 (+ haab-difference (* 365 difference))) |
292 18980)) | |
957 | 293 nil))) |
294 | |
92835
5e8d6a369c62
(generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents:
92636
diff
changeset
|
295 ;;;###cal-autoload |
93645
8b04f0b12fa3
(calendar-mayan-string-from-long-count): Rename
Glenn Morris <rgm@gnu.org>
parents:
93484
diff
changeset
|
296 (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
|
297 &optional noecho) |
f565309f0cab
(calendar-string-to-mayan-long-count)
Glenn Morris <rgm@gnu.org>
parents:
92607
diff
changeset
|
298 "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
|
299 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
|
300 (interactive (list (calendar-mayan-read-tzolkin-date) |
8b04f0b12fa3
(calendar-mayan-string-from-long-count): Rename
Glenn Morris <rgm@gnu.org>
parents:
93484
diff
changeset
|
301 (calendar-mayan-read-haab-date))) |
957 | 302 (let ((date (calendar-mayan-tzolkin-haab-on-or-before |
303 tzolkin-date haab-date | |
304 (+ 18980 (calendar-absolute-from-gregorian | |
305 (calendar-cursor-to-date)))))) | |
306 (if (not date) | |
307 (error "%s, %s does not exist in the Mayan calendar round" | |
308 (calendar-mayan-tzolkin-to-string tzolkin-date) | |
309 (calendar-mayan-haab-to-string haab-date)) | |
310 (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
|
311 (or noecho (calendar-mayan-print-date))))) |
8b04f0b12fa3
(calendar-mayan-string-from-long-count): Rename
Glenn Morris <rgm@gnu.org>
parents:
93484
diff
changeset
|
312 |
8b04f0b12fa3
(calendar-mayan-string-from-long-count): Rename
Glenn Morris <rgm@gnu.org>
parents:
93484
diff
changeset
|
313 (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
|
314 'calendar-mayan-next-round-date "23.1") |
957 | 315 |
92835
5e8d6a369c62
(generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents:
92636
diff
changeset
|
316 ;;;###cal-autoload |
93645
8b04f0b12fa3
(calendar-mayan-string-from-long-count): Rename
Glenn Morris <rgm@gnu.org>
parents:
93484
diff
changeset
|
317 (defun calendar-mayan-previous-round-date |
957 | 318 (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
|
319 "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
|
320 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
|
321 (interactive (list (calendar-mayan-read-tzolkin-date) |
8b04f0b12fa3
(calendar-mayan-string-from-long-count): Rename
Glenn Morris <rgm@gnu.org>
parents:
93484
diff
changeset
|
322 (calendar-mayan-read-haab-date))) |
957 | 323 (let ((date (calendar-mayan-tzolkin-haab-on-or-before |
324 tzolkin-date haab-date | |
325 (1- (calendar-absolute-from-gregorian | |
326 (calendar-cursor-to-date)))))) | |
327 (if (not date) | |
328 (error "%s, %s does not exist in the Mayan calendar round" | |
329 (calendar-mayan-tzolkin-to-string tzolkin-date) | |
330 (calendar-mayan-haab-to-string haab-date)) | |
331 (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
|
332 (or noecho (calendar-mayan-print-date))))) |
957 | 333 |
93645
8b04f0b12fa3
(calendar-mayan-string-from-long-count): Rename
Glenn Morris <rgm@gnu.org>
parents:
93484
diff
changeset
|
334 (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
|
335 'calendar-mayan-previous-round-date "23.1") |
8b04f0b12fa3
(calendar-mayan-string-from-long-count): Rename
Glenn Morris <rgm@gnu.org>
parents:
93484
diff
changeset
|
336 |
8b04f0b12fa3
(calendar-mayan-string-from-long-count): Rename
Glenn Morris <rgm@gnu.org>
parents:
93484
diff
changeset
|
337 (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
|
338 "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
|
339 Long count is a list (baktun katun tun uinal kin)" |
92853 | 340 (+ (* (nth 0 c) 144000) ; baktun |
341 (* (nth 1 c) 7200) ; katun | |
342 (* (nth 2 c) 360) ; tun | |
343 (* (nth 3 c) 20) ; uinal | |
344 (nth 4 c) ; kin (days) | |
92920
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
345 ;; Days before absolute date 0. |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
346 (- calendar-mayan-days-before-absolute-zero))) |
957 | 347 |
93646
a1ece6da90e8
(calendar-mayan-long-count-to-absolute): Keep old name as alias.
Glenn Morris <rgm@gnu.org>
parents:
93645
diff
changeset
|
348 (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
|
349 '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
|
350 |
92920
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
351 (defun calendar-mayan-long-count-common-era (lc) |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
352 "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
|
353 (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
|
354 (while (and base (= (car lc) (car base))) |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
355 (setq lc (cdr lc) |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
356 base (cdr base))) |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
357 (or (null lc) (> (car lc) (car base))))) |
957 | 358 |
92835
5e8d6a369c62
(generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents:
92636
diff
changeset
|
359 ;;;###cal-autoload |
93645
8b04f0b12fa3
(calendar-mayan-string-from-long-count): Rename
Glenn Morris <rgm@gnu.org>
parents:
93484
diff
changeset
|
360 (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
|
361 "Move cursor to Mayan long count DATE. |
cb0aac9dd8a3
(calendar-mayan-haab-month-name-array)
Glenn Morris <rgm@gnu.org>
parents:
92853
diff
changeset
|
362 Echo Mayan date unless NOECHO is non-nil." |
957 | 363 (interactive |
93484
0c5143f2417b
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93001
diff
changeset
|
364 (let (datum) |
0c5143f2417b
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93001
diff
changeset
|
365 (while (not (setq datum |
93645
8b04f0b12fa3
(calendar-mayan-string-from-long-count): Rename
Glenn Morris <rgm@gnu.org>
parents:
93484
diff
changeset
|
366 (calendar-mayan-string-from-long-count |
93484
0c5143f2417b
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93001
diff
changeset
|
367 (read-string |
0c5143f2417b
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93001
diff
changeset
|
368 "Mayan long count (baktun.katun.tun.uinal.kin): " |
0c5143f2417b
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93001
diff
changeset
|
369 (calendar-mayan-long-count-to-string |
0c5143f2417b
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93001
diff
changeset
|
370 (calendar-mayan-long-count-from-absolute |
0c5143f2417b
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93001
diff
changeset
|
371 (calendar-absolute-from-gregorian |
0c5143f2417b
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93001
diff
changeset
|
372 (calendar-current-date)))))) |
0c5143f2417b
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93001
diff
changeset
|
373 datum (if (calendar-mayan-long-count-common-era datum) |
0c5143f2417b
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93001
diff
changeset
|
374 (list datum))))) |
0c5143f2417b
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93001
diff
changeset
|
375 datum)) |
957 | 376 (calendar-goto-date |
377 (calendar-gregorian-from-absolute | |
93645
8b04f0b12fa3
(calendar-mayan-string-from-long-count): Rename
Glenn Morris <rgm@gnu.org>
parents:
93484
diff
changeset
|
378 (calendar-mayan-long-count-to-absolute date))) |
8b04f0b12fa3
(calendar-mayan-string-from-long-count): Rename
Glenn Morris <rgm@gnu.org>
parents:
93484
diff
changeset
|
379 (or noecho (calendar-mayan-print-date))) |
8b04f0b12fa3
(calendar-mayan-string-from-long-count): Rename
Glenn Morris <rgm@gnu.org>
parents:
93484
diff
changeset
|
380 |
8b04f0b12fa3
(calendar-mayan-string-from-long-count): Rename
Glenn Morris <rgm@gnu.org>
parents:
93484
diff
changeset
|
381 (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
|
382 'calendar-mayan-goto-long-count-date "23.1") |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
38422
diff
changeset
|
383 |
92607 | 384 (defvar date) |
385 | |
93784 | 386 ;; 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
|
387 ;;;###diary-autoload |
957 | 388 (defun diary-mayan-date () |
389 "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
|
390 (format "Mayan date: %s" (calendar-mayan-date-string date))) |
957 | 391 |
392 (provide 'cal-mayan) | |
393 | |
92589
c11e81a389cf
Unquote lambda functions. Add autoload cookies to functions formerly
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
394 ;; arch-tag: 54f35144-cd0f-4873-935a-a60129de07df |
957 | 395 ;;; cal-mayan.el ends here |