• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.9.5/emacs-92/emacs/lisp/calendar/

Lines Matching +refs:calendar +refs:read

1 ;;; cal-mayan.el --- calendar functions for the Mayan calendars
9 ;; Keywords: calendar
10 ;; Human-Keywords: Mayan calendar, Maya, calendar, diary
31 ;; This collection of functions implements the features of calendar.el and
32 ;; diary.el that deal with the Mayan calendar. It was written jointly by
58 (require 'calendar)
60 (defconst calendar-mayan-days-before-absolute-zero 1137142
61 "Number of days of the Mayan calendar epoch before absolute day 0.
66 (defconst calendar-mayan-haab-at-epoch '(8 . 18)
69 (defconst calendar-mayan-haab-month-name-array
73 (defconst calendar-mayan-tzolkin-at-epoch '(4 . 20)
76 (defconst calendar-mayan-tzolkin-names-array
80 (defun calendar-mayan-long-count-from-absolute (date)
82 (let ((long-count (+ date calendar-mayan-days-before-absolute-zero)))
93 (defun calendar-mayan-long-count-to-string (mayan-long-count)
97 (defun calendar-string-to-mayan-long-count (str)
108 (setq datum (read (substring str start end)))
111 (if (not (= (length rlc) 5)) (signal 'invalid-read-syntax nil)))
112 (invalid-read-syntax nil))
115 (defun calendar-mayan-haab-from-absolute (date)
117 (let* ((long-count (+ date calendar-mayan-days-before-absolute-zero))
120 (car calendar-mayan-haab-at-epoch)
121 (* 20 (1- (cdr calendar-mayan-haab-at-epoch))))
127 (defun calendar-mayan-haab-difference (date1 date2)
133 (defun calendar-mayan-haab-on-or-before (haab-date date)
137 (calendar-mayan-haab-difference
138 (calendar-mayan-haab-from-absolute 0) haab-date))
141 (defun calendar-next-haab-date (haab-date &optional noecho)
144 (interactive (list (calendar-read-mayan-haab-date)))
145 (calendar-goto-date
146 (calendar-gregorian-from-absolute
147 (calendar-mayan-haab-on-or-before
150 (calendar-absolute-from-gregorian (calendar-cursor-to-date))))))
151 (or noecho (calendar-print-mayan-date)))
153 (defun calendar-previous-haab-date (haab-date &optional noecho)
156 (interactive (list (calendar-read-mayan-haab-date)))
157 (calendar-goto-date
158 (calendar-gregorian-from-absolute
159 (calendar-mayan-haab-on-or-before
161 (1- (calendar-absolute-from-gregorian (calendar-cursor-to-date))))))
162 (or noecho (calendar-print-mayan-date)))
164 (defun calendar-mayan-haab-to-string (haab)
173 (aref calendar-mayan-haab-month-name-array (1- month))))))
175 (defun calendar-mayan-tzolkin-from-absolute (date)
177 (let* ((long-count (+ date calendar-mayan-days-before-absolute-zero))
178 (day (calendar-mod
179 (+ long-count (car calendar-mayan-tzolkin-at-epoch))
181 (name (calendar-mod
182 (+ long-count (cdr calendar-mayan-tzolkin-at-epoch))
186 (defun calendar-mayan-tzolkin-difference (date1 date2)
195 (defun calendar-mayan-tzolkin-on-or-before (tzolkin-date date)
198 (% (- date (calendar-mayan-tzolkin-difference
199 (calendar-mayan-tzolkin-from-absolute 0)
203 (defun calendar-next-tzolkin-date (tzolkin-date &optional noecho)
206 (interactive (list (calendar-read-mayan-tzolkin-date)))
207 (calendar-goto-date
208 (calendar-gregorian-from-absolute
209 (calendar-mayan-tzolkin-on-or-before
212 (calendar-absolute-from-gregorian (calendar-cursor-to-date))))))
213 (or noecho (calendar-print-mayan-date)))
215 (defun calendar-previous-tzolkin-date (tzolkin-date &optional noecho)
218 (interactive (list (calendar-read-mayan-tzolkin-date)))
219 (calendar-goto-date
220 (calendar-gregorian-from-absolute
221 (calendar-mayan-tzolkin-on-or-before
223 (1- (calendar-absolute-from-gregorian (calendar-cursor-to-date))))))
224 (or noecho (calendar-print-mayan-date)))
226 (defun calendar-mayan-tzolkin-to-string (tzolkin)
230 (aref calendar-mayan-tzolkin-names-array (1- (cdr tzolkin)))))
232 (defun calendar-mayan-tzolkin-haab-on-or-before (tzolkin-date haab-date date)
237 (calendar-mayan-haab-difference
238 (calendar-mayan-haab-from-absolute 0)
241 (calendar-mayan-tzolkin-difference
242 (calendar-mayan-tzolkin-from-absolute 0)
252 (defun calendar-read-mayan-haab-date ()
255 (haab-day (calendar-read
258 (haab-month-list (append calendar-mayan-haab-month-name-array
262 (completing-read "Haab uinal: "
265 (calendar-make-alist haab-month-list 1) t))))
268 (defun calendar-read-mayan-tzolkin-date ()
271 (tzolkin-count (calendar-read
274 (tzolkin-name-list (append calendar-mayan-tzolkin-names-array nil))
277 (completing-read "Tzolkin uinal: "
280 (calendar-make-alist tzolkin-name-list 1) t))))
283 (defun calendar-next-calendar-round-date
287 (interactive (list (calendar-read-mayan-tzolkin-date)
288 (calendar-read-mayan-haab-date)))
289 (let ((date (calendar-mayan-tzolkin-haab-on-or-before
291 (+ 18980 (calendar-absolute-from-gregorian
292 (calendar-cursor-to-date))))))
294 (error "%s, %s does not exist in the Mayan calendar round"
295 (calendar-mayan-tzolkin-to-string tzolkin-date)
296 (calendar-mayan-haab-to-string haab-date))
297 (calendar-goto-date (calendar-gregorian-from-absolute date))
298 (or noecho (calendar-print-mayan-date)))))
300 (defun calendar-previous-calendar-round-date
304 (interactive (list (calendar-read-mayan-tzolkin-date)
305 (calendar-read-mayan-haab-date)))
306 (let ((date (calendar-mayan-tzolkin-haab-on-or-before
308 (1- (calendar-absolute-from-gregorian
309 (calendar-cursor-to-date))))))
311 (error "%s, %s does not exist in the Mayan calendar round"
312 (calendar-mayan-tzolkin-to-string tzolkin-date)
313 (calendar-mayan-haab-to-string haab-date))
314 (calendar-goto-date (calendar-gregorian-from-absolute date))
315 (or noecho (calendar-print-mayan-date)))))
317 (defun calendar-absolute-from-mayan-long-count (c)
326 calendar-mayan-days-before-absolute-zero)))
328 (defun calendar-mayan-date-string (&optional date)
331 (let* ((d (calendar-absolute-from-gregorian
332 (or date (calendar-current-date))))
333 (tzolkin (calendar-mayan-tzolkin-from-absolute d))
334 (haab (calendar-mayan-haab-from-absolute d))
335 (long-count (calendar-mayan-long-count-from-absolute d)))
337 (calendar-mayan-long-count-to-string long-count)
338 (calendar-mayan-tzolkin-to-string tzolkin)
339 (calendar-mayan-haab-to-string haab))))
341 (defun calendar-print-mayan-date ()
345 (calendar-mayan-date-string (calendar-cursor-to-date t))))
347 (defun calendar-goto-mayan-long-count-date (date &optional noecho)
353 (calendar-string-to-mayan-long-count
354 (read-string "Mayan long count (baktun.katun.tun.uinal.kin): "
355 (calendar-mayan-long-count-to-string
356 (calendar-mayan-long-count-from-absolute
357 (calendar-absolute-from-gregorian
358 (calendar-current-date))))))))
359 (if (calendar-mayan-long-count-common-era datum)
362 (calendar-goto-date
363 (calendar-gregorian-from-absolute
364 (calendar-absolute-from-mayan-long-count date)))
365 (or noecho (calendar-print-mayan-date)))
367 (defun calendar-mayan-long-count-common-era (lc)
369 (let ((base (calendar-mayan-long-count-from-absolute 1)))
377 (format "Mayan date: %s" (calendar-mayan-date-string date)))