27:- module(holidays, [
28 todays_holiday/1
29 ]). 30
31:- dynamic current_holiday/2. 32
33current_holiday(0, none).
34
59todays_holiday(Holiday) :-
60 current_holiday(Time, Holiday),
61 get_time(Now),
62 Now - Time < 3600, !.
63todays_holiday(Holiday) :-
64 year(Year),
65 todays_holiday(Year, Holiday),
66 get_time(Now),
67 retractall(current_holiday(_, _)),
68 asserta(current_holiday(Now, Holiday)).
69
70todays_holiday(YY, april_fools_day) :-
71 date_between(YY-03-30, 12:00:00,
72 YY-04-02, 12:00:00).
73todays_holiday(YY, christmas) :-
74 date_between(YY-12-20, 12:00:00,
75 YY-12-27, 12:00:00).
76todays_holiday(YY, koningsdag) :-
77 date_between(YY-04-26, 12:00:00,
78 YY-04-28, 12:00:00).
79todays_holiday(YY, santiklaas) :-
80 date_between(YY-12-05, 12:00:00,
81 YY-12-06, 12:00:00).
82todays_holiday(YY, halloween) :-
83 date_between(YY-10-30, 12:00:00,
84 YY-11-01, 12:00:00).
85todays_holiday(YY, liberation_day) :-
86 date_between(YY-05-04, 12:00:00,
87 YY-05-06, 12:00:00).
88todays_holiday(YY, carnival) :-
89 carnival_date(Start, End),
90 Start = (YY-_-_),
91 End = (YY-_-_),
92 date_between(Start, 12:00:00,
93 End, 12:00:00).
94todays_holiday(YY, chinese_new_year) :-
95 chinese_new_year_date(Start, End),
96 Start = (YY-_-_),
97 End = (YY-_-_),
98 date_between(Start, 12:00:00,
99 End, 12:00:00).
100todays_holiday(_, none).
101
102carnival_date(2015-2-15, 2015-2-17).
103carnival_date(2016-2-07, 2016-2-09).
104carnival_date(2017-2-26, 2017-2-28).
105carnival_date(2018-2-11, 2018-2-13).
106carnival_date(2019-3-03, 2019-3-05).
107carnival_date(2020-2-23, 2020-2-25).
108carnival_date(2021-2-14, 2021-2-16).
109carnival_date(2022-2-27, 2022-2-29).
110carnival_date(2023-2-19, 2023-2-21).
111carnival_date(2024-2-11, 2025-2-13).
112carnival_date(2025-3-02, 2025-3-04).
113
114chinese_new_year_date(2015-02-19,2015-02-20).
115chinese_new_year_date(2016-02-08,2016-02-09).
116chinese_new_year_date(2017-01-28,2017-01-29).
117chinese_new_year_date(2018-02-16,2018-02-17).
118chinese_new_year_date(2019-02-05,2019-02-06).
119chinese_new_year_date(2020-01-25,2020-01-26).
120chinese_new_year_date(2021-02-12,2021-02-13).
121chinese_new_year_date(2022-02-01,2022-02-02).
122chinese_new_year_date(2023-01-22,2023-01-23).
123chinese_new_year_date(2024-02-10,2024-02-11).
124chinese_new_year_date(2025-01-29,2025-01-30).
125chinese_new_year_date(2026-02-17,2026-02-18).
126chinese_new_year_date(2027-02-06,2027-02-07).
127chinese_new_year_date(2028-01-26,2028-01-27).
128chinese_new_year_date(2029-02-13,2029-02-14).
129chinese_new_year_date(2030-02-03,2030-02-04).
130
136chinese_new_year_animal(2015, 'Sheep').
137chinese_new_year_animal(2016, 'Monkey').
138chinese_new_year_animal(2017, 'Rooster').
139chinese_new_year_animal(2018, 'Dog').
140chinese_new_year_animal(2019, 'Pig').
141chinese_new_year_animal(2020, 'Rat').
142chinese_new_year_animal(2021, 'Ox').
143chinese_new_year_animal(2022, 'Tiger').
144chinese_new_year_animal(2023, 'Rabbit').
145chinese_new_year_animal(2024, 'Dragon').
146chinese_new_year_animal(2025, 'Snake').
147chinese_new_year_animal(2026, 'Horse').
148chinese_new_year_animal(2027, 'Sheep').
149chinese_new_year_animal(2028, 'Monkey').
150chinese_new_year_animal(2029, 'Rooster').
151chinese_new_year_animal(2030, 'Dog').
152
153
157
158year(Year) :-
159 get_time(Now),
160 stamp_date_time(Now, Term, 'UTC'),
161 date_time_value(year, Term, Year).
162
163date_between(SDate, STime, EDate, ETime) :-
164 get_time(Now),
165 stamp(SDate, STime, Start), Now >= Start,
166 stamp(EDate, ETime, End), Now =< End.
167
168stamp(YY-MM-DD, H:M:S, Time) :-
169 date_time_stamp(date(YY,MM,DD,H,M,S,0,'UTC',-), Time)