;;; compiled by rms@mole.gnu.ai.mit.edu on Sat May 22 00:13:36 1993
;;; from file /home/fsf/rms/e19/lisp/cal-mayan.el
;;; emacs version 19.6.12.
;;; bytecomp version FSF 2.08
;;; optimization is on.

(require (quote calendar))
(defalias 'mayan-mod #[(m n) "	\n\"V \nV \n\\ )" [% m n v 0] 3 "\
Returns M mod N; value is *always* non-negative when N>0."])
(defalias 'mayan-adjusted-mod #[(m n) "	S\n\"T" [mayan-mod m n] 3 "\
Non-negative remainder of M/N with N instead of 0."])
(defconst calendar-mayan-days-before-absolute-zero 1137140 "\
Number of days of the Mayan calendar epoch before absolute day 0 (that is,
Dec 31, 0 (Gregorian)), according to the Goodman-Martinez-Thompson
correlation.  This correlation is not universally accepted, as it still a
subject of astro-archeological research.  Using 1232041 will give you the
correlation used by Spinden.")
(defconst calendar-mayan-haab-at-epoch (quote (8 . 18)) "\
Mayan haab date at the epoch.")
(byte-code "" [["Pop" "Uo" "Zip" "Zotz" "Tzec" "Xul" "Yaxkin" "Mol" "Chen" "Yax" "Zac" "Ceh" "Mac" "Kankin" "Muan" "Pax" "Kayab" "Cumku"] calendar-mayan-haab-month-name-array nil] 1)
(defconst calendar-mayan-tzolkin-at-epoch (quote (4 . 20)) "\
Mayan tzolkin date at the epoch.")
(byte-code "" [["Imix" "Ik" "Akbal" "Kan" "Chicchan" "Cimi" "Manik" "Lamat" "Muluc" "Oc" "Chuen" "Eb" "Ben" "Ix" "Men" "Cib" "Caban" "Etznab" "Cauac" "Ahau"] calendar-mayan-tzolkin-names-array nil] 1)
(defalias 'calendar-mayan-long-count-from-absolute #[(date) "	\\\n\"\n\"\"	\"\"\"\"\"	%.	" [date calendar-mayan-days-before-absolute-zero long-count / 144000 baktun % remainder 7200 katun 360 tun 20 uinal kin list] 6 "\
Compute the Mayan long count corresponding to the absolute DATE."])
(defalias 'calendar-mayan-long-count-to-string #[(mayan-long-count) "B\"" [apply format "%s.%s.%s.%s.%s" mayan-long-count] 4 "\
Convert MAYAN-LONG-COUNT into traditional written form."])
(defalias 'calendar-string-to-mayan-long-count #[(str) "	Gȏ!+" [nil str 0 cc c rlc condition (byte-code "	W) \"@! @\"% @BA)  GU6 \"ʇ" [cc c read-from-string str datum integerp signal invalid-read-syntax rlc 5 nil] 3) ((invalid-read-syntax)) reverse] 3 "\
Given STR, a string of format \"%d.%d.%d.%d.%d\", return list of nums."])
(defalias 'calendar-mayan-haab-from-absolute #[(date) "	\\\n@AS\"\\\\\"\"	\"T	,B" [date calendar-mayan-days-before-absolute-zero long-count % calendar-mayan-haab-at-epoch * 20 365 day-of-haab day / month] 6 "\
Convert absolute DATE into a Mayan haab date (a pair)."])
(defalias 'calendar-mayan-haab-difference #[(date1 date2) "\nAAZ\"\n@@Z\\\"" [mayan-mod * date2 date1 20 365] 4 "\
Number of days from Mayan haab date DATE1 to the next occurrence of Mayan
haab date DATE2."])
(defalias 'calendar-mayan-haab-on-or-before #[(haab-date date) "!\"Z\"Z" [date % calendar-mayan-haab-difference calendar-mayan-haab-from-absolute 0 haab-date 365] 6 "\
Absolute date of latest HAAB-DATE on or before absolute DATE."])
(defalias 'calendar-next-haab-date #[(haab-date &optional noecho) " @ A@ AA@ @ A@ AA@S\"\\\nVg \n\"\\\"Z\n\"UY \"Ub \"Ug \nT\n\n,S\"S\"S\"[S\"\\\\\\\\+\\\"!!  " [calendar-goto-date calendar-gregorian-from-absolute calendar-mayan-haab-on-or-before haab-date calendar-cursor-to-date year day month * 31 day-of-year 2 / 4 23 10 % 0 100 400 365 noecho calendar-print-mayan-date] 11 "\
Move cursor to next instance of Mayan HAAB-DATE. 
Echo Mayan date if NOECHO is t." (list (calendar-read-mayan-haab-date))])
(defalias 'calendar-previous-haab-date #[(haab-date &optional noecho) " @ A@ AA@ @ A@ AA@S\"\\\nVg \n\"\\\"Z\n\"UY \"Ub \"Ug \nT\n\n,S\"S\"S\"[S\"\\\\\\\\+S\"!!  " [calendar-goto-date calendar-gregorian-from-absolute calendar-mayan-haab-on-or-before haab-date calendar-cursor-to-date year day month * 31 day-of-year 2 / 4 23 10 % 0 100 400 365 noecho calendar-print-mayan-date] 11 "\
Move cursor to previous instance of Mayan HAAB-DATE. 
Echo Mayan date if NOECHO is t." (list (calendar-read-mayan-haab-date))])
(defalias 'calendar-mayan-haab-to-string #[(haab) "A@U 	\" 	\nSH#*" [haab day month 19 format "%d Uayeb" "%d %s" calendar-mayan-haab-month-name-array] 6 "\
Convert Mayan haab date (a pair) into its traditional written form."])
(defalias 'calendar-mayan-tzolkin-from-absolute #[(date) "	\\\n@\\\"\nA\\\"+B" [date calendar-mayan-days-before-absolute-zero long-count mayan-adjusted-mod calendar-mayan-tzolkin-at-epoch 13 day 20 name] 3 "\
Convert absolute DATE into a Mayan tzolkin date (a pair)."])
(defalias 'calendar-mayan-tzolkin-difference #[(date1 date2) "@	@ZA	AZ\nZ\"\"\"\\\"*" [date2 date1 name-difference number-difference mayan-mod * 3 20 13 260] 7 "\
Number of days from Mayan tzolkin date DATE1 to the next occurrence of
Mayan tzolkin date DATE2."])
(defalias 'calendar-mayan-tzolkin-on-or-before #[(tzolkin-date date) "!\"Z\"Z" [date % calendar-mayan-tzolkin-difference calendar-mayan-tzolkin-from-absolute 0 tzolkin-date 260] 6 "\
Absolute date of latest TZOLKIN-DATE on or before absolute DATE."])
(defalias 'calendar-next-tzolkin-date #[(tzolkin-date &optional noecho) " @ A@ AA@ @ A@ AA@S\"\\\nVg \n\"\\\"Z\n\"UY \"Ub \"Ug \nT\n\n,S\"S\"S\"[S\"\\\\\\\\+\\\"!!  " [calendar-goto-date calendar-gregorian-from-absolute calendar-mayan-tzolkin-on-or-before tzolkin-date calendar-cursor-to-date year day month * 31 day-of-year 2 / 4 23 10 % 0 100 400 365 260 noecho calendar-print-mayan-date] 11 "\
Move cursor to next instance of Mayan TZOLKIN-DATE. 
Echo Mayan date if NOECHO is t." (list (calendar-read-mayan-tzolkin-date))])
(defalias 'calendar-previous-tzolkin-date #[(tzolkin-date &optional noecho) " @ A@ AA@ @ A@ AA@S\"\\\nVg \n\"\\\"Z\n\"UY \"Ub \"Ug \nT\n\n,S\"S\"S\"[S\"\\\\\\\\+S\"!!  " [calendar-goto-date calendar-gregorian-from-absolute calendar-mayan-tzolkin-on-or-before tzolkin-date calendar-cursor-to-date year day month * 31 day-of-year 2 / 4 23 10 % 0 100 400 365 noecho calendar-print-mayan-date] 11 "\
Move cursor to previous instance of Mayan TZOLKIN-DATE. 
Echo Mayan date if NOECHO is t." (list (calendar-read-mayan-tzolkin-date))])
(defalias 'calendar-mayan-tzolkin-to-string #[(tzolkin) "\n@\nASH#" [format "%d %s" tzolkin calendar-mayan-tzolkin-names-array] 5 "\
Convert Mayan tzolkin date (a pair) into its traditional written form."])
(defalias 'calendar-mayan-tzolkin-haab-on-or-before #[(tzolkin-date haab-date date) "!\"!\"Z		\"U/ 	\"\\Z\"Z+" [calendar-mayan-haab-difference calendar-mayan-haab-from-absolute 0 haab-date haab-difference calendar-mayan-tzolkin-difference calendar-mayan-tzolkin-from-absolute tzolkin-date tzolkin-difference difference % 5 date mayan-mod * 365 18980] 8 "\
Absolute date of latest date on or before date that is Mayan TZOLKIN-DATE
and HAAB-DATE; returns nil if such a tzolkin-haab combination is impossible."])
(defalias 'calendar-read-mayan-haab-date #[nil "\"W \"\n\n\"$!\n#\"A,B" [t completion-ignore-case calendar-read "Haab kin (0-19): " (lambda (x) (and (>= x 0) (< x 20))) haab-day append calendar-mayan-haab-month-name-array 5 ("Uayeb") haab-month-list assoc capitalize completing-read "Haab uinal: " mapcar list nil calendar-make-alist 1 haab-month] 7 "\
Prompt for a Mayan haab date"])
(defalias 'calendar-read-mayan-tzolkin-date #[nil "\"\"		\"$!	#\"A,B" [t completion-ignore-case calendar-read "Tzolkin kin (1-13): " (lambda (x) (and (> x 0) (< x 14))) tzolkin-count append calendar-mayan-tzolkin-names-array nil tzolkin-name-list assoc capitalize completing-read "Tzolkin uinal: " mapcar list calendar-make-alist 1 tzolkin-name] 7 "\
Prompt for a Mayan tzolkin date"])
(defalias 'calendar-next-calendar-round-date #[(tzolkin-date haab-date &optional noecho) "	\n @ A@ AA@ @ A@ AA@S\"\\	Vc 	\"\\\"Z	\"UU \"U^ \"Uc 	T		,S\"S\"S\"[S\"\\\\\\\\+\\# 	!\n!# !!  )" [calendar-mayan-tzolkin-haab-on-or-before tzolkin-date haab-date calendar-cursor-to-date year day month * 31 day-of-year 2 / 4 23 10 % 0 100 400 365 18980 date error "%s, %s does not exist in the Mayan calendar round" calendar-mayan-tzolkin-to-string calendar-mayan-haab-to-string calendar-goto-date calendar-gregorian-from-absolute noecho calendar-print-mayan-date] 11 "\
Move cursor to next instance of Mayan HAAB-DATE TZOKLIN-DATE combination.
Echo Mayan date if NOECHO is t." (list (calendar-read-mayan-tzolkin-date) (calendar-read-mayan-haab-date))])
(defalias 'calendar-previous-calendar-round-date #[(tzolkin-date haab-date &optional noecho) "	\n @ A@ AA@ @ A@ AA@S\"\\	Vc 	\"\\\"Z	\"UU \"U^ \"Uc 	T		,S\"S\"S\"[S\"\\\\\\\\+S# 	!\n!# !!  )" [calendar-mayan-tzolkin-haab-on-or-before tzolkin-date haab-date calendar-cursor-to-date year day month * 31 day-of-year 2 / 4 23 10 % 0 100 400 365 date error "%s, %s does not exist in the Mayan calendar round" calendar-mayan-tzolkin-to-string calendar-mayan-haab-to-string calendar-goto-date calendar-gregorian-from-absolute noecho calendar-print-mayan-date] 11 "\
Move cursor to previous instance of Mayan TZOKLIN-DATE HAAB-DATE
combination.  Echo Mayan date if NOECHO is t." (list (calendar-read-mayan-tzolkin-date) (calendar-read-mayan-haab-date))])
(defalias 'calendar-absolute-from-mayan-long-count #[(c) "	@\"	A@\"	8\"	8\"	8	[\\\\\\\\\\" [* c 144000 7200 2 360 3 20 4 calendar-mayan-days-before-absolute-zero] 6 "\
Compute the absolute date corresponding to the Mayan Long
Count $c$, which is a list (baktun katun tun uinal kin)"])
(defalias 'calendar-print-mayan-date #[nil "  !@  !A@  !AA@ ) !@ 3 !A@ > !AA@S\"\\V \"\\\"Z\"Uq \"Uz \"U T,S\"S\"S\"[S\"\\\\\\\\+!!!!!!$," [calendar-cursor-to-date error "Cursor is not on a date!" year day month * 31 day-of-year 2 / 4 23 10 % 0 100 400 365 d calendar-mayan-tzolkin-from-absolute tzolkin calendar-mayan-haab-from-absolute haab calendar-mayan-long-count-from-absolute long-count message "Mayan date: Long count = %s; tzolkin = %s; haab = %s" calendar-mayan-long-count-to-string calendar-mayan-tzolkin-to-string calendar-mayan-haab-to-string] 7 "\
Show the Mayan long count, tzolkin, and haab equivalents of the date
under the cursor." nil])
(defalias 'calendar-goto-mayan-long-count-date #[(date &optional noecho) "!!!  " [calendar-goto-date calendar-gregorian-from-absolute calendar-absolute-from-mayan-long-count date noecho calendar-print-mayan-date] 4 "\
Move cursor to Mayan long count DATE.  Echo Mayan date unless NOECHO is t." (byte-code "	  @ A@ AA@	\n @\n A@	 AA@	\nS\"\\\nVs \n\"\\\"Z\"Ud \"Un \"Us T,S\"S\"S\"[S\"\\\\\\\\+!!\"!! ) 	)C" [nil lc calendar-string-to-mayan-long-count read-string "Mayan long count (baktun.katun.tun.uinal.kin): " calendar-mayan-long-count-to-string calendar-mayan-long-count-from-absolute calendar-current-date year day month * 31 day-of-year 2 / 4 23 10 % 0 100 400 365 datum calendar-mayan-long-count-common-era] 12)])
(defalias 'calendar-mayan-long-count-common-era #[(lc) "! @\n@U A\nA ?$ @\n@V)" [calendar-mayan-long-count-from-absolute 1 base lc] 3 "\
T if long count represents date in the Common Era."])
(defalias 'diary-mayan-date #[nil "@A@AA@@A@AA@\nS\"\\VU \"\\\"Z	\"UG 	\"UP 	\"UU T,	S\"	S\"	S\"[	S\"\\\\\\\\+!!!!!!$," [date year day month * 31 day-of-year 2 / 4 23 10 % 0 100 400 365 d calendar-mayan-tzolkin-from-absolute tzolkin calendar-mayan-haab-from-absolute haab calendar-mayan-long-count-from-absolute long-count format "Mayan date: Long count = %s; tzolkin = %s; haab = %s" calendar-mayan-long-count-to-string calendar-mayan-tzolkin-to-string calendar-mayan-haab-to-string] 7 "\
Show the Mayan long count, haab, and tzolkin dates as a diary entry."])
(provide (quote cal-mayan))
