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