Skip to content

Commit a6246ed

Browse files
authored
Merge pull request #242 from n-studio/hk
Add missing HK holidays
2 parents 9719c6f + 937c932 commit a6246ed

File tree

2 files changed

+151
-93
lines changed

2 files changed

+151
-93
lines changed

METHODS.yml

+6
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,9 @@ methods:
2424
arguments: date
2525
lunar_to_solar:
2626
arguments: year, month, day, region
27+
to_the_next_weekday_after:
28+
arguments: date
29+
to_the_second_weekday_after:
30+
arguments: date
31+
to_previous_day_if_leap_year:
32+
arguments: date

hk.yaml

+145-93
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,11 @@
11
# Hong Kong holiday definitions for the Holidays gem!
22

3-
# Days not included in the definitions (yet):
4-
# Ching Ming Festival
5-
# The Birthday of the Buddha
6-
# Tuen Ng Festival
7-
# Chinese Mid-Autumn Festival
8-
# Chung Yeung Festival
9-
103
# Source:
114
# http://www.gov.hk/en/about/abouthk/holiday/
5+
# https://en.wikipedia.org/wiki/Public_holidays_in_Hong_Kong
126

137
months:
148
0:
15-
- name: Lunar New Year's Day
16-
regions: [hk]
17-
function: cn_new_lunar_day(year)
18-
observed: to_monday_if_sunday(date)
19-
- name: The second day of Lunar New Year
20-
regions: [hk]
21-
function: cn_new_lunar_day(year)
22-
function_modifier: 1
23-
observed: to_monday_if_sunday(date)
24-
- name: The third day of Lunar New Year
25-
regions: [hk]
26-
function: cn_new_lunar_day(year)
27-
function_modifier: 2
28-
observed: to_weekday_if_boxing_weekend(date)
299
- name: Good Friday
3010
regions: [hk]
3111
function: easter(year)
@@ -43,16 +23,58 @@ months:
4323
regions: [hk]
4424
mday: 1
4525
observed: to_monday_if_sunday(date)
26+
- name: Lunar New Year's Day
27+
regions: [hk]
28+
function: lunar_to_solar(year, month, day, region)
29+
mday: 1
30+
observed: to_monday_if_sunday(date)
31+
- name: The second day of Lunar New Year
32+
regions: [hk]
33+
function: lunar_to_solar(year, month, day, region)
34+
mday: 1
35+
observed: to_the_weekday_after(date)
36+
- name: The third day of Lunar New Year
37+
regions: [hk]
38+
function: lunar_to_solar(year, month, day, region)
39+
mday: 1
40+
observed: to_the_second_weekday_after(date)
41+
4:
42+
- name: Ching Ming Festival
43+
regions: [hk]
44+
mday: 5
45+
observed: to_previous_day_if_leap_year(date)
46+
- name: Buddha's Birthday
47+
regions: [hk]
48+
function: lunar_to_solar(year, month, day, region)
49+
mday: 8
50+
observed: to_monday_if_sunday(date)
4651
5:
4752
- name: Labour Day
4853
regions: [hk]
4954
mday: 1
5055
observed: to_monday_if_sunday(date)
56+
- name: Tuen Ng Festival
57+
regions: [hk]
58+
function: lunar_to_solar(year, month, day, region)
59+
mday: 5
60+
observed: to_monday_if_sunday(date)
5161
7:
5262
- name: Hong Kong Special Administrative Region Establishment Day
5363
regions: [hk]
5464
mday: 1
5565
observed: to_monday_if_sunday(date)
66+
8:
67+
- name: The day following the Chinese Mid-Autumn Festival
68+
regions: [hk]
69+
function: lunar_to_solar(year, month, day, region)
70+
mday: 16
71+
observed: to_monday_if_sunday(date)
72+
9:
73+
- name: Chung Yeung Festival
74+
regions: [hk]
75+
function: lunar_to_solar(year, month, day, region)
76+
mday: 9
77+
observed: to_monday_if_sunday(date)
5678
10:
5779
- name: National Day
5880
regions: [hk]
@@ -68,78 +90,6 @@ months:
6890
mday: 26
6991
observed: to_weekday_if_boxing_weekend(date)
7092

71-
methods:
72-
cn_new_lunar_day:
73-
arguments: year
74-
ruby: |
75-
month_day = case year
76-
when 1930, 1949, 1987, 2025, 2063, 2082, 2101, 2112, 2131, 2150, 2207, 2245, 2253, 2283, 2321
77-
[1, 29]
78-
when 1931, 1950, 1969, 1988, 2007, 2026, 2045, 2083, 2091, 2102, 2121, 2159, 2197, 2208, 2216, 2227, 2246, 2265, 2303, 2322, 2341, 2379
79-
[2, 17]
80-
when 1932, 1951, 1970, 1989, 2027, 2046, 2114, 2179, 2198, 2209, 2247, 2266, 2304, 2323, 2342, 2361, 2399
81-
[2, 6]
82-
when 1933, 2009, 2028, 2047, 2066, 2085, 2115, 2161, 2199, 2210, 2229, 2267, 2305, 2316, 2324, 2335, 2381
83-
[1, 26]
84-
when 1934, 1953, 2037, 2048, 2067, 2086, 2105, 2116, 2181, 2189, 2211, 2257, 2268, 2306, 2325, 2336
85-
[2, 14]
86-
when 1935, 1943, 1992, 2038, 2106, 2144, 2201, 2212, 2258, 2296, 2307, 2326, 2364
87-
[2, 4]
88-
when 1936, 1955, 2001, 2039, 2058, 2088, 2107, 2164, 2183, 2221, 2259, 2278, 2308, 2327, 2373
89-
[1, 24]
90-
when 1937, 1975, 2032, 2040, 2051, 2070, 2108, 2127, 2146, 2165, 2252, 2260, 2271, 2290, 2309, 2328, 2347, 2366
91-
[2, 11]
92-
when 1938, 1957, 1976, 1995, 2014, 2033, 2071, 2109, 2128, 2185, 2272, 2291, 2329, 2348, 2367, 2386
93-
[1, 31]
94-
when 1939, 1996, 2015, 2053, 2072, 2110, 2129, 2292, 2330, 2368, 2387
95-
[2, 19]
96-
when 1940, 1959, 2016, 2035, 2081, 2130, 2149, 2187, 2206, 2225, 2236, 2255, 2312, 2350, 2358, 2369
97-
[2, 8]
98-
when 1941, 1952, 1971, 1990, 2074, 2093, 2123, 2142, 2180, 2248, 2294, 2343, 2351, 2362
99-
[1, 27]
100-
when 1942, 1961, 1972, 1991, 2056, 2075, 2094, 2124, 2143, 2200, 2276, 2295, 2344, 2363
101-
[2, 15]
102-
when 1944, 1963, 1982, 2020, 2096, 2134, 2153, 2172, 2191, 2202, 2240, 2286, 2354, 2392
103-
[1, 25]
104-
when 1945, 1964, 1983, 2010, 2029, 2162, 2192, 2230, 2249, 2317, 2382
105-
[2, 13]
106-
when 1946, 2003, 2022, 2041, 2052, 2098, 2147, 2155, 2166, 2223, 2242, 2261, 2299, 2310, 2375, 2394
107-
[2, 1]
108-
when 1947, 2004, 2042, 2050, 2080, 2118, 2137, 2194, 2270, 2289, 2300, 2338, 2376
109-
[1, 22]
110-
when 1948, 1994, 2013, 2024, 2043, 2089, 2119, 2138, 2157, 2176, 2195, 2214, 2320, 2396
111-
[2, 10]
112-
when 1954, 1973, 2011, 2057, 2068, 2087, 2125, 2163, 2231, 2277, 2288, 2345, 2383
113-
[2, 3]
114-
when 1956, 2002, 2021, 2059, 2078, 2097, 2135, 2154, 2173, 2184, 2203, 2222, 2241, 2279, 2287, 2298, 2355, 2374, 2393
115-
[2, 12]
116-
when 1958, 1977, 2034, 2140, 2178, 2235, 2254, 2273, 2311, 2349, 2360, 2398
117-
[2, 18]
118-
when 1960, 1979, 1998, 2006, 2017, 2036, 2055, 2104, 2169, 2188, 2218, 2226, 2237, 2256, 2275, 2313, 2332, 2370, 2389
119-
[1, 28]
120-
when 1962, 1981, 2000, 2019, 2065, 2076, 2084, 2095, 2133, 2152, 2171, 2190, 2220, 2239, 2285, 2315, 2334, 2353, 2372, 2391
121-
[2, 5]
122-
when 1965, 1984, 2030, 2049, 2060, 2079, 2117, 2136, 2174, 2182, 2193, 2204, 2250, 2269, 2280, 2318, 2337, 2356
123-
[2, 2]
124-
when 1966, 2023, 2061, 2099, 2186, 2262, 2281, 2357, 2395
125-
[1, 21]
126-
when 1967, 1986, 2005, 2062, 2100, 2168, 2233, 2244, 2263, 2282, 2301, 2339, 2377, 2385, 2388
127-
[2, 9]
128-
when 1968, 2044, 2090, 2120, 2139, 2158, 2177, 2196, 2215, 2234, 2264, 2302, 2340, 2359, 2378, 2397
129-
[1, 30]
130-
when 1974, 1993, 2012, 2031, 2069, 2077, 2126, 2145, 2156, 2175, 2213, 2232, 2251, 2297, 2346, 2365, 2384
131-
[1, 23]
132-
when 1978, 1997, 2008, 2054, 2073, 2092, 2103, 2111, 2122, 2141, 2160, 2217, 2228, 2274, 2293, 2331, 2380
133-
[2, 7]
134-
when 1980, 1999, 2018, 2064, 2113, 2132, 2151, 2170, 2219, 2238, 2284, 2314, 2333, 2352, 2371, 2390
135-
[2, 16]
136-
when 1985, 2148, 2167, 2205, 2224, 2243
137-
[2, 20]
138-
when 2319
139-
[2, 21]
140-
end
141-
Date.civil(year, month_day[0], month_day[1])
142-
14393
tests:
14494
- given:
14595
date: '2016-01-01'
@@ -285,3 +235,105 @@ tests:
285235
options: ["observed"]
286236
expect:
287237
name: "Boxing Day"
238+
- given:
239+
date: '2023-01-02'
240+
regions: ["hk"]
241+
options: ["observed"]
242+
expect:
243+
name: "New Year's Day"
244+
- given:
245+
date: '2023-01-23'
246+
regions: ["hk"]
247+
options: ["observed"]
248+
expect:
249+
name: "Lunar New Year's Day"
250+
- given:
251+
date: '2023-01-24'
252+
regions: ["hk"]
253+
options: ["observed"]
254+
expect:
255+
name: "The second day of Lunar New Year"
256+
- given:
257+
date: '2023-01-25'
258+
regions: ["hk"]
259+
options: ["observed"]
260+
expect:
261+
name: "The third day of Lunar New Year"
262+
- given:
263+
date: '2023-04-05'
264+
regions: ["hk"]
265+
options: ["observed"]
266+
expect:
267+
name: "Ching Ming Festival"
268+
- given:
269+
date: '2023-04-07'
270+
regions: ["hk"]
271+
options: ["observed"]
272+
expect:
273+
name: "Good Friday"
274+
- given:
275+
date: '2023-04-08'
276+
regions: ["hk"]
277+
options: ["observed"]
278+
expect:
279+
name: "The day following Good Friday"
280+
- given:
281+
date: '2023-04-10'
282+
regions: ["hk"]
283+
options: ["observed"]
284+
expect:
285+
name: "Easter Monday"
286+
- given:
287+
date: '2023-05-01'
288+
regions: ["hk"]
289+
options: ["observed"]
290+
expect:
291+
name: "Labour Day"
292+
- given:
293+
date: '2023-05-26'
294+
regions: ["hk"]
295+
options: ["observed"]
296+
expect:
297+
name: "Buddha's Birthday"
298+
- given:
299+
date: '2023-06-22'
300+
regions: ["hk"]
301+
options: ["observed"]
302+
expect:
303+
name: "Tuen Ng Festival"
304+
- given:
305+
date: '2023-07-01'
306+
regions: ["hk"]
307+
options: ["observed"]
308+
expect:
309+
name: "Hong Kong Special Administrative Region Establishment Day"
310+
- given:
311+
date: '2023-09-30'
312+
regions: ["hk"]
313+
options: ["observed"]
314+
expect:
315+
name: "The day following the Chinese Mid-Autumn Festival"
316+
- given:
317+
date: '2023-10-02'
318+
regions: ["hk"]
319+
options: ["observed"]
320+
expect:
321+
name: "National Day"
322+
- given:
323+
date: '2023-10-23'
324+
regions: ["hk"]
325+
options: ["observed"]
326+
expect:
327+
name: "Chung Yeung Festival"
328+
- given:
329+
date: '2023-12-25'
330+
regions: ["hk"]
331+
options: ["observed"]
332+
expect:
333+
name: "Christmas Day"
334+
- given:
335+
date: '2023-12-26'
336+
regions: ["hk"]
337+
options: ["observed"]
338+
expect:
339+
name: "Boxing Day"

0 commit comments

Comments
 (0)