
(require (quote calendar))

(provide (quote holidays))

(defun holidays nil "\
Display the holidays for last month, this month, and next month.
This function is suitable for execution in a .emacs file." (interactive) (byte-code "È @AA@ +)" [date displayed-month displayed-year nil calendar-current-date list-calendar-holidays] 3))

(defun check-calendar-holidays (date) "\
Check the list of holidays for any that occur on DATE.
The value returned is a list of strings of relevant holiday descriptions.
The holidays are those in the list calendar-holidays." (byte-code "	@	AA@ + 	@@\"\" @A\"A ," [displayed-month date displayed-year h holiday-list nil calendar-holiday-list calendar-date-equal append] 6))

(defun calendar-cursor-holidays nil "\
Find holidays for the date specified by the cursor in the calendar window." (interactive) (byte-code "ǈ!  !!!
#	#
?/ 	\"l G X= !l !qǉ	\" 
#ceb!ɉ!!-" [date date-string holiday-list holiday-string msg holiday-buffer buffer-read-only nil mode-line-format t message "Checking holidays..." calendar-cursor-to-date error "Cursor is not on a date!" calendar-date-string check-calendar-holidays mapconcat identity ";  " format "%s:  %s" "No holidays known for %s" screen-width get-buffer-create "--------------------------%s%%-" erase-buffer "
" set-buffer-modified-p display-buffer "Checking holidays...done"] 18))

(defun mark-calendar-holidays nil "\
Mark notable days in the calendar window." (interactive) (byte-code "Ĉ! 
  
@@\"
A )!" [mark-holidays-in-calendar t holiday-list calendar-holiday-marker nil message "Marking holidays..." calendar-holiday-list mark-visible-calendar-date "Marking holidays...done"] 6))

(defun list-calendar-holidays nil "\
Create a buffer containing the holidays for the current calendar window.
The holidays are those in the list calendar-notable-days.  Returns t if any
holidays are found, nil if not." (interactive) (byte-code "ǈ! 

? !ǂ !qǉ	\"	$

\"T
\")\"$

\"T
\")	!!% #ceb!̉	!!-" [holiday-list m1 displayed-month y1 displayed-year m2 y2 nil holiday-buffer buffer-read-only macro-y mode-line-format t message "Looking up holidays..." calendar-holiday-list "Looking up holidays...none found" get-buffer-create + * 12 -1 % / 1 format "-------------Notable Dates from %s, %d to %s, %d%%-" calendar-month-name erase-buffer mapconcat (lambda (x) (concat (calendar-date-string (car x)) ": " (car (cdr x)))) "
" set-buffer-modified-p display-buffer "Looking up holidays...done"] 21))

(defun calendar-holiday-list nil "\
Form the list of holidays that occur on dates in the calendar window.
The holidays are those in the list calendar-holidays." (byte-code "	8 @@\"!@A  @A\"# !. 
\"*A 
\"*" [p calendar-holidays holiday-list nil function-name holidays intern format "calendar-holiday-function-%s" funcall append sort calendar-date-compare] 8))

(defun calendar-holiday-function-fixed (x) "\
Returns the corresponding Gregorian date, if visible in the window, to
month, year where month is (car X) and year is (car (cdr X)).  If it is
visible, the value returned is the list (((month day year) string)) where
string is (car (nthcdr 2 X)).  Returns nil if it is not visible in the
current calendar window." (byte-code "	@!	A@!	\"@!\"Z$\"T\")VH 
EDC-" [month x day string m displayed-month y displayed-year macro-y eval nthcdr 2 + * 12 -1 11 % / 9] 11))

(defun calendar-holiday-function-float (x) "\
Returns the corresponding Gregorian date, if visible in the window, to the
n-th occurrence (negative counts from the end of the month) of dayname in
month, year where month is (car X), year is (car (cdr X)), n is
(car (nthcdr 2 X)).  If it is visible, the value returned is the list
(((month day year) string)) where string is (car (nthcdr 3 X)).
Returns nil if it is not visible in the current calendar window." (byte-code "	@!	A@!	\"@!	\"@!\"Z$		\"T	\")VS 
$DC." [month x dayname n string m displayed-month y displayed-year macro-y eval nthcdr 2 3 + * 12 -1 11 % / 9 calendar-nth-named-day] 15))

(defun calendar-holiday-function-julian (x) "\
Returns the corresponding Gregorian date, if visible in the window, to the
Julian date month, year where month is (car X) and year is (car (cdr X)).
If it is visible, the value returned is the list (((month day year) string))
where string is (car (nthcdr 2 X)).  Returns nil if it is not visible in the
current calendar window." (byte-code "	@!	A@!	\"@!	
\"$\"T\")	\"$\"T\"	)E@EA@EAA@
E@EA@EAA@

S\"\\V \"\\\"Z
\"U 
\"\" 
\"U T,
S\"
S\"
S\"[
S\"%+	\"U	\"\"	\"U U',SH	E@	\"UD	\"\"N	\"UUU\\aSH	EA@	\"Uz	\"\"	\"UU肗SH	EAA@
	\"U	\"\"	\"UUSH	E@	\"U	\"\"	\"UU	SH	EA@	\"U#	\"\"-	\"U4U;@SH	EAA@

S\"\\V\"\\\"Z
\"Uy
\"\"
\"UT,
S\"
S\"
S\"[
S\"%+!!AA@AA@W


E!!!DC).." [month x day string m1 displayed-month y1 displayed-year m2 y2 year nil macro-y start-date day-of-year end-date julian-start julian-end julian-y1 julian-y2 date eval nthcdr 2 + * 12 -1 % / 1 31 23 4 10 0 /= 100 400 365 29 [31 28 31 30 31 30 31 31 30 31 30 31] calendar-julian-from-absolute calendar-gregorian-from-absolute calendar-absolute-from-julian calendar-date-is-visible-p] 67))

(defun calendar-holiday-function-islamic (x) "\
Returns the corresponding Gregorian date, if visible in the window, to the
Islamic date month, day where month is (car X) and day is (car (cdr X)).
If it is visible, the value returned is the list (((month day year) string))
where string is (car (nthcdr 2 X)).  Returns nil if it is not visible in
the current calendar window." (byte-code "	@!	A@!	\"@!E@EA@EAA@E@EA@EAA@
S\"\\V \"\\\"Z\"Ux \"\" \"U T,S\"S\"S\"[S\"%+!@	AA@
	W ̂
\"	Z$\"T	\"
)	V

E!!!DC)." [month x day string islamic-date displayed-month displayed-year year day-of-year m y date nil macro-y eval nthcdr 2 calendar-islamic-from-absolute 15 + * 31 / 23 4 10 % 0 /= 100 400 365 1 12 -1 7 calendar-gregorian-from-absolute calendar-absolute-from-islamic calendar-date-is-visible-p] 26))

(defun calendar-holiday-function-hebrew (x) "\
Returns the corresponding Gregorian date, if visible in the window, to the
Hebrew date month, day where month is (car X) and day is (car (cdr X)).
If it is visible, the value returned is the list (((month day year) string))
where string is (car (nthcdr 2 X)).  Returns nil if it is not visible in
the current calendar window." (byte-code "	@!	A@!	\"@!W! Z$ \\W0 Z3 \\W? ZB \\WN ZQ \\W] Z` \\%>E
	\"$\"T\")	\"$\"T\"	)E@EA@EAA@
E@EA@EAA@

S\"\\V,\"\\\"Z
\"U
\"\"#
\"U,T,
S\"
S\"
S\"[
S\"%+	\"Ua	\"\"k	\"UrUy~SH	E@	\"U	\"\"	\"UUSH	EA@	\"U	\"\"	\"UUSH	EAA@
	\"U	\"\"	\"UU %SH	E@	\"U>	\"\"H	\"UOUV[SH	EA@	\"Uu	\"\"	\"UUSH	EAA@

S\"\\V\"\\\"Z
\"U
\"\"
\"UT,
S\"
S\"
S\"[
S\"%+!!AA@AA@W$&


E!!!ADC).-+" [month x day string displayed-month m1 y1 displayed-year m2 y2 year nil macro-y start-date day-of-year end-date hebrew-start hebrew-end hebrew-y1 hebrew-y2 date eval nthcdr 2 list 11 1 10 9 3 8 4 7 5 + * 12 -1 % / 31 23 0 /= 100 400 365 29 [31 28 31 30 31 30 31 31 30 31 30 31] calendar-hebrew-from-absolute 6 calendar-gregorian-from-absolute calendar-absolute-from-hebrew calendar-date-is-visible-p] 68))

(defun calendar-holiday-function-if (x) "\
Conditional holiday for dates in the calendar window.
The boolean condition is (car X).  If t, the holiday (car (cdr X)) is
checked.  If nil, the holiday (car (cdr (cdr X))), if there, is checked." (byte-code "	@! 	A@ 	AA@
3 
@\"!
A- 
A\"0 !**" [boolean x h function-name holidays eval intern format "calendar-holiday-function-%s" funcall] 6))

(defun calendar-holiday-function-advent nil "\
Date of Advent, if visible in calendar window." (byte-code "	\"
$\"T\")E@EA@EAA@E@EA@EAA@
S\"\\
V 
\"\\\"Z\"U~ \"\" \"U T,S\"S\"S\"[S\"%+\"!! DC)*" [year displayed-year month displayed-month macro-y advent day day-of-year + * 12 -1 % / calendar-gregorian-from-absolute calendar-dayname-on-or-before 0 3 31 2 23 4 10 /= 100 400 365 calendar-date-is-visible-p "Advent"] 25))

(defun calendar-holiday-function-easter-etc nil "\
List of dates related to Easter, as visible in calendar window." (byte-code "V 	? \"T\"\"\"\"[\"\\\"\"%\"UJ UJ \"WR TS E@EA@EAA@
	E@EA@	EAA@
	S\"\\V \"\\\"Z
\"U 
\"\" 
\"U T,
S\"
S\"
S\"[
S\"%+Z\\\"!DZ!DZ!DEZ!DZ!DZ!DZ!DZ!DZ!DZ!DZ!D\\!D\\!D\\!@ DA \\!B D\\!C DD \\!E D&F !	G F !\"." [displayed-month all-christian-calendar-holidays nil century displayed-year shifted-epact adjusted-epact paschal-moon month day year day-of-year abs-easter mandatory optional output-list 5 / 100 % + 14 * 11 19 3 4 8 25 30 0 1 10 31 2 23 /= 400 365 calendar-dayname-on-or-before 7 calendar-gregorian-from-absolute "Easter Sunday" "Good Friday" 46 "Ash Wednesday" list 63 "Septuagesima Sunday" 56 "Sexagesima Sunday" 49 "Shrove Sunday" 48 "Shrove Monday" 47 "Shrove Tuesday" "Passion Sunday" "Palm Sunday" "Maundy Thursday" 35 "Rogation Sunday" 39 "Ascension Sunday" "Pentecost (Whitsunday)" 50 "Whitmunday" "Trinity Sunday" 60 "Corpus Christi" filter-visible-calendar-holidays append] 57))

(defun calendar-holiday-function-rosh-hashanah-etc nil "\
List of dates related to Rosh Hashanah, as visible in calendar window." (byte-code "W	 V  \\E!
!\\\"D
\\!D
\\!D
\\!D
\\!D%
Z\"!D
S!D
T!D
\"Ui 
\\l 
\\!D
\\\"!D
\\!D
\\!D
\\!D
\\!D
\\!D
\\!D
\\!D
\\!D&! !\"," [displayed-month nil abs-r-h displayed-year mandatory optional output-list all-hebrew-calendar-holidays 8 11 calendar-absolute-from-hebrew 7 1 3761 list calendar-gregorian-from-absolute format "Rosh HaShanah %d" 9 "Yom Kippur" 14 "Sukkot" 21 "Shemini Atzeret" 22 "Simchat Torah" calendar-dayname-on-or-before 6 4 "Selichot (night)" "Erev Rosh HaShannah" "Rosh HaShanah (second day)" % 3 2 "Tzom Gedaliah" "Shabbat Shuvah" "Erev Yom Kippur" 13 "Erev Sukkot" 15 "Sukkot (second day)" 16 "Hol Hamoed Sukkot (first day)" 17 "Hol Hamoed Sukkot (second day)" 18 "Hol Hamoed Sukkot (third day)" 19 "Hol Hamoed Sukkot (fourth day)" 20 "Hoshannah Rabbah" filter-visible-calendar-holidays append] 39))

(defun calendar-holiday-function-hanukkah nil "\
List of dates related to Hanukkah, as visible in calendar window." (byte-code ">
\"	$\"T\")	
\"U6 
\"\"? 
\"UE 	UL ڂP 	SH
E@	
\"Ud 
\"\"m 
\"Us 	Uz ڂ~ 	SH
EA@	
\"U 
\"\" 
\"U 	U ڂ 	SH
EAA@	
\"U 
\"\" 
\"U 	U ڂ 	SH
E@	
\"U 
\"\"
\"U		Uڂ	SH
EA@	
\"U+
\"\"4
\"U:	UAڂE	SH
EAA@S\"\\	V	\"\\\"Z	\"U\"\"\"U	T		,S\"S\"S\"[S\"%+!AA@E!

S!D
!D
T!D
\\!D
\\!D
\\!D
\\!D
\\!D
\\!D&	!**" [displayed-month m y displayed-year macro-y h-y month day year day-of-year abs-h (10 11 12 1 2) + * 12 -1 1 % / calendar-hebrew-from-absolute 4 0 /= 100 400 2 29 [31 28 31 30 31 30 31 31 30 31 30 31] 31 23 10 365 calendar-absolute-from-hebrew 9 25 filter-visible-calendar-holidays list calendar-gregorian-from-absolute "Erev Hanukkah" "Hanukkah (first day)" "Hanukkah (second day)" "Hanukkah (third day)" 3 "Hanukkah (fourth day)" "Hanukkah (fifth day)" 5 "Hanukkah (sixth day)" 6 "Hanukkah (seventh day)" 7 "Hanukkah (eighth day)"] 63))

(defun calendar-holiday-function-passover-etc nil "\
List of dates related to Passover, as visible in calendar window." (byte-code "W
 (\\E!
!D
\\!DD
Z\"!D
Z\"!D
\"UF 
ZI 
Z!D
Z!D
Z!D
\"!j 
Zm 
Z!D
Z\"Z!D
Z\"!D
S\"!D
S!D
T!D
\\!D
\\!D
\\!D
\\!D
\\!D
\\!D
\\!D
\"! 
\\ 
\"U 
\\ 
\\!D
\\!D
\\!D
\\!D
\\!D&!$!\"," [displayed-month nil abs-p displayed-year mandatory optional output-list all-hebrew-calendar-holidays 7 calendar-absolute-from-hebrew 1 15 3760 calendar-gregorian-from-absolute "Passover" 50 "Shavuot" list calendar-dayname-on-or-before 6 43 "Shabbat Shekalim" 30 "Shabbat Zachor" % 2 33 31 "Fast of Esther" "Erev Purim" "Purim" zerop 28 29 "Shushan Purim" 14 "Shabbat Parah" "Shabbat HaHodesh" "Shabbat HaGadol" "Erev Passover" "Passover (second day)" "Hol Hamoed Passover (first day)" 3 "Hol Hamoed Passover (second day)" 4 "Hol Hamoed Passover (third day)" 5 "Hol Hamoed Passover (fourth day)" "Passover (seventh day)" "Passover (eighth day)" 12 "Yom HaShoah" 18 19 20 "Yom HaAtzma'ut" "Lag BaOmer" "Yom Yerushalim" 49 "Erev Shavuot" 51 "Shavuot (second day)" filter-visible-calendar-holidays append] 62))

(defun calendar-holiday-function-tisha-b-av-etc nil "\
List of dates around Tisha B'Av, as visible in calendar window." (byte-code "W	 V X \\E!
\"U* 
Z- 
Z!D
\"!D
\"UG 
TH 
!D
\\\"!DF!)" [displayed-month nil abs-t-a displayed-year 5 9 calendar-absolute-from-hebrew 3760 filter-visible-calendar-holidays calendar-gregorian-from-absolute % 7 6 20 21 "Tzom Tammuz" calendar-dayname-on-or-before "Shabbat Hazon" "Tisha B'Av" "Shabbat Nahamu"] 16))

(defun filter-visible-calendar-holidays (l) "\
Return a list of all visible holidays of those on L." (byte-code "
! 
@@! 
@C\"
A *" [visible nil p l calendar-date-is-visible-p append] 5))
