diff --git a/Makefile b/Makefile index adf7d142..1e4334d9 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,9 @@ -default: validate +default: test validate: bundle exec ruby lib/validation/run.rb -test: +test: validate bundle exec rspec .PHONY: validate,test diff --git a/SYNTAX.md b/SYNTAX.md index 3a4388aa..48d6f435 100644 --- a/SYNTAX.md +++ b/SYNTAX.md @@ -103,7 +103,7 @@ Then the holiday will be returned. This is especially useful for holidays like " ### Year ranges -Certain holidays in various countries are only in effect during specific year ranges. For example, a new holiday might come into effect that is only valid after a specific year (say, 2017). +Certain holidays in various countries are only in effect during specific year ranges. For example, a new holiday might come into effect that is only valid after a specific year (say, 2017). After is inclusive, if you put after: 2017 it will apply on 2017 and after. To address this we have the ability to specify these 'year ranges' in the definition. The gem will then only return a match on a date that adheres to these rules. diff --git a/au.yaml b/au.yaml index f020d749..11b461e1 100644 --- a/au.yaml +++ b/au.yaml @@ -5,6 +5,7 @@ # - http://www.docep.wa.gov.au/lr/LabourRelations/Content/Wages%20and%20Conditions/Public%20Holidays/Public_Holidays.html # - http://www.wst.tas.gov.au/employment_info/public_holidays # - https://www.fairwork.gov.au/leave/public-holidays/list-of-public-holidays +# - http://www.business.vic.gov.au/victorian-public-holidays-and-daylight-saving/victorian-public-holidays --- months: 0: @@ -24,19 +25,50 @@ months: function: easter(year) year_ranges: - after: 2017 + - name: Easter Sunday + regions: [au_sa] + function: easter(year) + year_ranges: + - after: 2024 + - name: Easter Sunday + regions: [au_wa] + function: easter(year) + year_ranges: + - after: 2021 + - name: Easter Sunday + regions: [au_nt] + function: easter(year) + year_ranges: + - after: 2022 + - name: Easter Sunday + regions: [au_nt] + function: easter(year) + year_ranges: + - limited: 2022 - name: Easter Monday regions: [au] function: easter(year) function_modifier: 1 + - name: Friday before the AFL Grand Final + regions: [au_vic] + function: afl_grand_final(year) 1: - - name: New Year's Day - regions: [au, au_nsw, au_vic, au_act, au_sa, au_wa, au_nt, au_qld] + - name: New Year's Day # All states except TAS have an additional public holiday for New Year's Day + regions: [au_nsw, au_vic, au_act, au_wa, au_nt, au_qld] mday: 1 - observed: to_monday_if_weekend(date) - - name: New Year's Day + - name: New Year's Day # SA only just get this now. Can delete after this year. + regions: [au_sa] + mday: 1 + year_ranges: + - after: 2023 + - name: New Year's Day # TAS move New Year's Day to monday on the weekend regions: [au_tas] mday: 1 function: to_monday_if_weekend(date) + - name: Additional public holiday for New Year's Day # All states except TAS have additional PH for New Year's Day + regions: [au_nsw, au_vic, au_act, au_wa, au_nt, au_qld, au_sa] + mday: 1 + function: additional_holiday_on_monday_if_on_weekend(date) - name: Australia Day regions: [au] mday: 26 @@ -67,17 +99,50 @@ months: week: 2 wday: 1 4: + - name: ANZAC Day # ANZAC DAY ACTUAL + regions: [au_nsw, au_sa, au_tas, au_vic, au_act, au_wa] + mday: 25 + year_ranges: + - before: 2025 + - name: ANZAC Day # ANZAC DAY OBSERVED - no additional recognised + regions: [au_nt, au_qld] + mday: 25 + observed: to_monday_if_weekend(date) + year_ranges: + - before: 2025 + - name: Additional public holiday for ANZAC Day # ADDITIONAL ANZAC DAY + regions: [au_sa, au_act] + mday: 25 + function: additional_anzac_on_monday_if_on_weekend(date) + year_ranges: + - before: 2025 + - name: ANZAC Day # ANZAC DAY ACTUAL + regions: [au_nsw, au_sa, au_tas, au_vic, au_wa, au_nt] + mday: 25 + year_ranges: + - after: 2026 - name: ANZAC Day - regions: [au] + regions: [au_act] mday: 25 + observed: to_monday_if_weekend(date) + year_ranges: + - limited: 2026 - name: ANZAC Day - regions: [au_nsw, au_vic, au_qld, au_nt, au_act, au_sa, au_tas] + regions: [au_act] mday: 25 observed: to_monday_if_sunday(date) + year_ranges: + - after: 2027 - name: ANZAC Day + regions: [au_qld] + mday: 25 + function: to_monday_if_sunday(date) + year_ranges: + - after: 2026 + - name: Additional public holiday for ANZAC Day # ADDITIONAL ANZAC DAY regions: [au_wa] mday: 25 - observed: to_monday_if_weekend(date) + function: additional_anzac_on_monday_if_on_weekend(date) 5: - name: Labour Day regions: [au_qld] @@ -89,6 +154,10 @@ months: - name: May Public Holiday regions: [au_sa] function: may_pub_hol_sa(year) + - name: ACT Reconciliation Day + regions: [au_act] + mday: 27 + observed: to_next_monday(date) 6: - name: Foundation Day regions: [au_wa] @@ -98,6 +167,14 @@ months: regions: [au_act, au_nsw, au_sa, au_tas, au_nt, au_vic] week: 2 wday: 1 + year_ranges: + - before: 2022 + - name: King's Birthday + regions: [au_act, au_nsw, au_sa, au_tas, au_nt, au_vic] + week: 2 + wday: 1 + year_ranges: + - after: 2023 - name: Queen's Birthday regions: [au_qld] function: qld_queens_birthday_june(year) @@ -115,19 +192,45 @@ months: regions: [au_qld_brisbane] week: -3 wday: 3 + - name: Picnic Day + regions: [au_nt] + wday: 1 + week: 1 9: - name: Queen's Birthday regions: [au_wa] week: -1 wday: 1 + year_ranges: + - before: 2022 + - name: King's Birthday + regions: [au_wa] + week: -1 + wday: 1 + year_ranges: + - after: 2025 + - name: King's Birthday + regions: [au_wa] + mday: 25 + year_ranges: + - limited: 2023 + - name: King's Birthday + regions: [au_wa] + mday: 23 + year_ranges: + - limited: 2024 - name: "Family & Community Day" regions: [au_act] week: -1 wday: 1 + year_ranges: + - before: 2017 + - name: Day of mourning for Queen Elizabeth II + regions: [au, au_nsw, au_act, au_sa, au_tas, au_vic, au_wa, au_nt, au_qld] + mday: 22 + year_ranges: + - limited: 2022 10: - - name: Friday before the AFL Grand Final - regions: [au_vic] - function: afl_grand_final(year) - name: Labour Day regions: [au_act, au_nsw, au_sa] week: 1 @@ -140,6 +243,10 @@ months: regions: [au_qld] function: qld_queens_bday_october(year) observed: to_monday_if_weekend(date) + - name: King's Birthday + regions: [au_qld] + function: qld_kings_bday_october(year) + observed: to_monday_if_weekend(date) - name: Royal Hobart Show regions: [au_tas_south] function: hobart_show_day(year) @@ -152,28 +259,47 @@ months: wday: 1 week: 1 - name: Melbourne Cup Day - regions: [au_vic_melbourne] + regions: [au_vic_melbourne, au_vic] week: 1 wday: 2 12: - - name: Christmas Day # CHRISTMAS DAY - All states except SA observe on 27th (and 25th) if 25th is a Sunday - regions: [au_qld, au_nsw, au_act, au_tas, au_wa, au_vic, au_nt] + - name: Christmas Day # SA CHRISTMAS DAY STATIC EXCEPT SATURDAY - Excluding Saturday for SA, is moved to monday + regions: [au_sa] mday: 25 - observed: to_tuesday_if_sunday_or_monday_if_saturday(date) - - name: Boxing Day - regions: [au_nsw, au_vic, au_qld, au_act, au_wa] + function: sa_christmas_exclude_saturday(date) + - name: Christmas Day # CHRISTMAS DAY STATIC ACTUAL - Recognised by ALL states expect for SA + regions: [au_act, au_nsw, au_qld, au_tas, au_vic, au_wa, au_nt] + mday: 25 + - name: Additional public holiday for Christmas Day # ADDITIONAL CHRISTMAS DAY - additional christmas day moves two days forward on the weekend, Recognised by ALL states expect for NT and SA + regions: [au_act, au_nsw, au_qld, au_tas, au_vic, au_wa] + mday: 25 + function: additional_holiday_if_on_weekend(date) + - name: Additional public holiday for Christmas Day # ADDITIONAL CHRISTMAS DAY TO MONDAY FOR NT - additional christmas day on the weekend is always on monday before boxing day in NT + regions: [au_nt] + mday: 25 + function: additional_holiday_on_monday_if_on_weekend(date) + - name: Additional public holiday for Christmas Day # ADDITIONAL CHRISTMAS DAY TO MONDAY FOR SA EXCEPT ON SATURDAY - additional christmas day for SA excludes saturday + regions: [au_sa] + mday: 25 + function: additional_holiday_on_monday_if_on_sunday(date) + - name: Boxing Day # BOXING DAY STATIC ACTUAL - Recognised by ALL states expect for NT/SA + regions: [au_act, au_nsw, au_qld, au_vic, au_wa] + mday: 26 + - name: Boxing Day # BOXING DAY SA SUBSTITUTE - SA only substitutes Boxing Day if it falls on a Monday + regions: [au_sa, au_nt] + mday: 26 + function: to_tuesday_if_monday(date) + - name: Additional public holiday Boxing Day # ADDITIONAL BOXING DAY - Recognised by ALL states expect for NT / TAS + regions: [au_act, au_nsw, au_qld, au_vic, au_wa, au_sa, au_nt] + mday: 26 + function: additional_holiday_if_on_weekend(date) + - name: Boxing Day # BOXING DAY OBSERVED - Only NT & TAS as they dont have an additional observed if on weekend + regions: [au_tas] # SA to be moved to additional setup in 2021 (2020 has no additionals) mday: 26 observed: to_tuesday_if_sunday_or_monday_if_saturday(date) - - name: Boxing Day - regions: [au_tas, au_nt] - function: to_weekday_if_boxing_weekend_from_year(year) - name: Proclamation Day regions: [au_sa] function: to_weekday_if_boxing_weekend_from_year_or_to_tuesday_if_monday(year) - - name: Christmas Day # CHRISTMAS DAY - SA observes on 26th if 25th is a Sunday (Boxing Day goes to 27th) - regions: [au_sa] - mday: 25 - observed: to_monday_if_weekend(date) methods: afl_grand_final: @@ -186,6 +312,33 @@ methods: Date.civil(2016, 9, 30) when 2017 Date.civil(2017, 9, 29) + when 2018 + Date.civil(2018, 9, 28) + when 2019 + Date.civil(2019, 9, 27) + when 2020 + Date.civil(2020, 10, 23) + when 2021 + Date.civil(2021, 9, 24) + when 2022 + Date.civil(2022, 9, 23) + when 2023 + Date.civil(2023, 9, 29) + when 2024 + Date.civil(2024, 9, 27) + when 2025 + Date.civil(2025, 9, 26) + end + qld_kings_bday_october: + # http://www.justice.qld.gov.au/fair-and-safe-work/industrial-relations/public-holidays/dates + # celebrated twice in 2012 + # in october again from 2016 + arguments: year + source: | + if year >= 2023 + Holidays::Factory::DateCalculator.day_of_month_calculator.call(year, 10, 1, 1) + else + nil end qld_queens_bday_october: # http://www.justice.qld.gov.au/fair-and-safe-work/industrial-relations/public-holidays/dates @@ -193,7 +346,7 @@ methods: # in october again from 2016 arguments: year source: | - if year >= 2016 + if year <= 2022 && year >= 2016 Holidays::Factory::DateCalculator.day_of_month_calculator.call(year, 10, 1, 1) elsif year == 2012 1 @@ -257,8 +410,181 @@ methods: else Date.civil(year, 5, Holidays::Factory::DateCalculator.day_of_month_calculator.call(year, 5, :third, :monday)) end + additional_holiday_if_on_weekend: + # https://www.fairwork.gov.au/leave/public-holidays + # https://www.fairwork.gov.au/leave/public-holidays/list-of-public-holidays/list-of-public-holidays-2021 + # If Boxing Day/Christmas fall on a weekend (Saturday / Sunday), the public holiday rates will be paid on both the weekend date and the observed date (e. Monday / Tuesday) and the additional day will use the term 'Additional public holiday'. + arguments: date + source: | + if [0,6].include?(date.wday) + date += 2 + date + else + nil + end + additional_anzac_on_monday_if_on_weekend: + # https://www.fairwork.gov.au/leave/public-holidays + # https://www.fairwork.gov.au/leave/public-holidays/list-of-public-holidays/list-of-public-holidays-2021 + # SA and WA recognise additional anzac holidays on monday if on the weekend + arguments: date + source: | + if [0,6].include?(date.wday) + date += 2 if date.wday == 6 + date += 1 if date.wday == 0 + date + else + nil + end + additional_holiday_on_monday_if_on_weekend: + # NT has additional christmas day on monday before boxing day if on the weekend instead of tuesday + # Also Additional new year's day is observed on monday if on the weekend + arguments: date + source: | + if [0,6].include?(date.wday) + date += 2 if date.wday == 6 + date += 1 if date.wday == 0 + date + else + nil + end + additional_holiday_on_monday_if_on_sunday: + # SA doesn't get an additional christmas day if it falls on a saturday + arguments: date + source: | + if date.wday == 0 + date += 1 + date + else + nil + end + sa_christmas_exclude_saturday: + arguments: date + source: | + if date.wday == 6 + date += 2 + date + else + date + end + to_monday_if_saturday_or_to_tuesday_if_sunday_or_monday: # NT/SA has boxing day on tuesday if on monday instead + arguments: date + source: | + if [6,0].include?(date.wday) + date += 2 + date + elsif date.wday == 1 + date += 1 + date + else + date + end + to_tuesday_if_monday: # SA moves boxing day to after christmas day instead + arguments: date + source: | + if date.wday == 1 + date += 1 + date + else + date + end tests: + - given: + date: '2015-04-27' + regions: ["au_qld"] + options: ["observed"] + expect: + name: "ANZAC Day" + - given: + date: ['2020-04-25', '2021-04-25', '2022-04-25', '2023-04-25', '2024-04-25', '2025-04-25'] + regions: ["au_nsw", "au_act", "au_vic", "au_tas", "au_sa", "au_wa"] + expect: + name: 'ANZAC Day' + - given: + date: ['2020-04-27', '2021-04-26', '2022-04-25', '2023-04-25', '2024-04-25', '2025-04-25'] + regions: ["au_qld", "au_nt"] + options: ["observed"] + expect: + name: 'ANZAC Day' + - given: + date: ['2026-04-25', '2027-04-25'] + regions: ["au_nsw", "au_vic", "au_tas", "au_sa", "au_wa", "au_nt"] + expect: + name: 'ANZAC Day' + - given: + date: ['2026-04-27'] + regions: ["au_act"] + options: ["observed"] + expect: + name: 'ANZAC Day' + - given: + # QLD: stays on 25th (only moves if Sunday) + date: ['2026-04-25', '2028-04-25', '2029-04-25', '2030-04-25', '2031-04-25', '2033-04-25', '2034-04-25', '2035-04-25'] + regions: ["au_qld"] + expect: + name: 'ANZAC Day' + - given: + # QLD: observed on Monday when falls on Sunday + date: ['2027-04-26', '2032-04-26'] + regions: ["au_qld"] + options: ["observed"] + expect: + name: 'ANZAC Day' + - given: + # ACT 2027+: stays on 25th (only moves if Sunday) + date: ['2028-04-25', '2029-04-25', '2030-04-25', '2031-04-25', '2033-04-25', '2034-04-25', '2035-04-25'] + regions: ["au_act"] + expect: + name: 'ANZAC Day' + - given: + # ACT 2027+: observed on Monday when falls on Sunday + date: ['2027-04-26', '2032-04-26'] + regions: ["au_act"] + options: ["observed"] + expect: + name: 'ANZAC Day' + - given: + # additional on Monday if falls on Weekend + date: ['2021-04-26', '2026-04-27', '2027-04-26'] + regions: ["au_wa"] + expect: + name: 'Additional public holiday for ANZAC Day' + - given: + date: '2015-04-25' + regions: ["au_wa"] + expect: + name: 'ANZAC Day' + - given: + date: '2015-04-27' + regions: ["au_wa"] + options: ["observed"] + expect: + name: 'Additional public holiday for ANZAC Day' + - given: + date: '2026-04-27' + regions: ["au_nsw", "au_vic", "au_tas", "au_sa", "au_nt", "au_qld"] + expect: + holiday: false + - given: + date: '2021-12-25' + regions: ["au_qld"] + expect: + name: 'Christmas Day' + - given: + date: '2021-12-27' + regions: ["au_qld"] + expect: + name: 'Additional public holiday for Christmas Day' + - given: + date: '2021-12-26' + regions: ["au_qld"] + expect: + name: 'Boxing Day' + - given: + date: '2021-12-28' + regions: ["au_qld"] + expect: + name: 'Additional public holiday Boxing Day' - given: date: '2013-10-07' regions: ["au_qld"] @@ -284,11 +610,21 @@ tests: regions: ["au_qld"] expect: name: "Queen's Birthday" + - given: + date: ['2023-10-02',"2024-10-07"] + regions: ["au_qld"] + expect: + name: "King's Birthday" - given: date: ['2014-09-29', '2015-09-28', '2016-09-26'] regions: ["au_wa"] expect: name: "Queen's Birthday" + - given: + date: ['2023-09-25','2024-09-23', '2025-09-29'] + regions: ["au_wa"] + expect: + name: "King's Birthday" - given: date: '2014-09-29' regions: ["au_act"] @@ -304,14 +640,20 @@ tests: regions: ["au_act"] expect: name: 'Family & Community Day' + - given: + date: ['2017-05-29', '2018-05-28', '2019-05-27', '2020-06-01'] + regions: ["au_act"] + options: ["observed"] + expect: + name: 'ACT Reconciliation Day' - given: date: '2014-01-26' - regions: ["au_qld"] + regions: ["au"] expect: name: 'Australia Day' - given: date: '2014-01-27' - regions: ["au_qld"] + regions: ["au"] options: ["observed"] expect: name: 'Australia Day' @@ -365,21 +707,11 @@ tests: regions: ["au_tas_north"] expect: name: 'Recreation Day' - - given: - date: '2015-12-26' - regions: ["au_tas"] - expect: - holiday: false - given: date: '2015-11-14' regions: ["au_qld_brisbane"] expect: holiday: false - - given: - date: '2015-12-26' - regions: ["au_nt"] - expect: - holiday: false - given: date: '2016-12-27' regions: ["au_sa"] @@ -390,16 +722,6 @@ tests: regions: ["au_nt"] expect: name: 'Christmas Day' - - given: - date: '2014-11-04' - regions: ["au_vic"] - expect: - holiday: false - - given: - date: '2015-11-03' - regions: ["au_vic"] - expect: - holiday: false - given: date: '2016-12-25' regions: ["au_vic"] @@ -415,17 +737,6 @@ tests: regions: ["au_sa"] expect: holiday: false - - given: - date: '2015-12-26' - regions: ["au_sa"] - expect: - holiday: false - - given: - date: '2015-04-27' - regions: ["au_qld"] - options: ["observed"] - expect: - holiday: false - given: date: '2014-11-14' regions: ["au_qld"] @@ -433,12 +744,17 @@ tests: holiday: false - given: date: '2014-11-04' - regions: ["au_vic_melbourne"] + regions: ["au_vic_melbourne", "au_vic"] expect: name: 'Melbourne Cup Day' - given: date: '2015-11-03' - regions: ["au_vic_melbourne"] + regions: ["au_vic_melbourne", "au_vic"] + expect: + name: 'Melbourne Cup Day' + - given: + date: '2019-11-05' + regions: ["au_vic", "au_vic_melbourne"] expect: name: 'Melbourne Cup Day' - given: @@ -456,6 +772,46 @@ tests: regions: ["au_vic"] expect: name: 'Friday before the AFL Grand Final' + - given: + date: '2018-09-28' + regions: ["au_vic"] + expect: + name: 'Friday before the AFL Grand Final' + - given: + date: '2019-09-27' + regions: ["au_vic"] + expect: + name: 'Friday before the AFL Grand Final' + - given: + date: '2020-10-23' + regions: ["au_vic"] + expect: + name: 'Friday before the AFL Grand Final' + - given: + date: '2021-09-24' + regions: ["au_vic"] + expect: + name: 'Friday before the AFL Grand Final' + - given: + date: '2022-09-23' + regions: ["au_vic"] + expect: + name: 'Friday before the AFL Grand Final' + - given: + date: '2023-09-29' + regions: ["au_vic"] + expect: + name: 'Friday before the AFL Grand Final' + - given: + date: '2024-09-27' + regions: ["au_vic"] + expect: + name: 'Friday before the AFL Grand Final' + - given: + date: '2025-09-26' + regions: ["au_vic"] + expect: + name: 'Friday before the AFL Grand Final' - given: date: '2005-05-16' regions: ["au_sa"] @@ -481,17 +837,6 @@ tests: regions: ["au_sa"] expect: name: 'March Public Holiday' - - given: - date: '2015-04-25' - regions: ["au_qld", "au_wa"] - expect: - name: 'ANZAC Day' - - given: - date: '2015-04-27' - regions: ["au_wa"] - options: ["observed"] - expect: - name: 'ANZAC Day' - given: date: '2015-12-26' regions: ["au_qld"] @@ -501,13 +846,18 @@ tests: date: '2015-12-28' regions: ["au_qld"] options: ["observed"] + expect: + name: "Additional public holiday Boxing Day" + - given: + date: '2020-12-26' + regions: ["au_qld"] expect: name: "Boxing Day" - given: date: '2015-12-26' regions: ["au_sa"] expect: - holiday: false + name: "Boxing Day" - given: date: '2015-12-28' regions: ["au_sa"] @@ -516,23 +866,30 @@ tests: - given: date: '2015-12-26' regions: ["au_tas"] + expect: + name: "Boxing Day" + - given: + date: '2015-12-26' + regions: ["au_tas"] + options: ["observed"] expect: holiday: false - given: date: '2015-12-28' regions: ["au_tas"] + options: ["observed"] expect: name: "Boxing Day" - given: date: '2015-12-26' regions: ["au_nt"] expect: - holiday: false + name: "Boxing Day" - given: date: '2015-12-28' regions: ["au_nt"] expect: - name: "Boxing Day" + name: "Additional public holiday Boxing Day" - given: date: '2012-02-13' regions: ["au_tas_south"] @@ -562,9 +919,8 @@ tests: - given: date: '2016-12-27' regions: ["au_qld"] - options: ["observed"] expect: - name: 'Christmas Day' + name: 'Additional public holiday for Christmas Day' - given: date: '2016-12-25' regions: ["au_nsw"] @@ -573,9 +929,8 @@ tests: - given: date: '2016-12-27' regions: ["au_nsw"] - options: ["observed"] expect: - name: 'Christmas Day' + name: 'Additional public holiday for Christmas Day' - given: date: '2016-12-25' regions: ["au_act"] @@ -584,9 +939,8 @@ tests: - given: date: '2016-12-27' regions: ["au_act"] - options: ["observed"] expect: - name: 'Christmas Day' + name: 'Additional public holiday for Christmas Day' - given: date: '2016-12-25' regions: ["au_tas"] @@ -595,9 +949,8 @@ tests: - given: date: '2016-12-27' regions: ["au_tas"] - options: ["observed"] expect: - name: 'Christmas Day' + name: 'Additional public holiday for Christmas Day' - given: date: '2016-12-25' regions: ["au_wa"] @@ -606,20 +959,29 @@ tests: - given: date: '2016-12-27' regions: ["au_wa"] - options: ["observed"] expect: - name: 'Christmas Day' + name: 'Additional public holiday for Christmas Day' - given: date: '2016-12-25' regions: ["au_sa"] expect: name: 'Christmas Day' + - given: + date: '2021-12-25' + regions: ["au_sa"] + expect: + holiday: false + - given: + date: '2022-12-25' + regions: ["au_sa"] + expect: + name: 'Christmas Day' - given: date: '2016-12-26' regions: ["au_sa"] options: ["observed"] expect: - name: 'Christmas Day' + name: 'Additional public holiday for Christmas Day' - given: date: '2016-12-25' regions: ["au_nsw"] @@ -628,9 +990,8 @@ tests: - given: date: '2016-12-27' regions: ["au_nsw"] - options: ["observed"] expect: - name: 'Christmas Day' + name: 'Additional public holiday for Christmas Day' - given: date: '2016-12-25' regions: ["au_act"] @@ -639,9 +1000,8 @@ tests: - given: date: '2016-12-27' regions: ["au_act"] - options: ["observed"] expect: - name: 'Christmas Day' + name: 'Additional public holiday for Christmas Day' - given: date: '2016-12-25' regions: ["au_tas"] @@ -650,9 +1010,8 @@ tests: - given: date: '2016-12-27' regions: ["au_tas"] - options: ["observed"] expect: - name: 'Christmas Day' + name: 'Additional public holiday for Christmas Day' - given: date: '2016-12-25' regions: ["au_wa"] @@ -661,9 +1020,8 @@ tests: - given: date: '2016-12-27' regions: ["au_wa"] - options: ["observed"] expect: - name: 'Christmas Day' + name: 'Additional public holiday for Christmas Day' - given: date: '2016-12-25' regions: ["au_sa"] @@ -672,49 +1030,65 @@ tests: - given: date: '2016-12-26' regions: ["au_sa"] - options: ["observed"] expect: - name: 'Christmas Day' + name: 'Additional public holiday for Christmas Day' - given: date: '2016-12-27' regions: ["au_vic"] - options: ["observed"] expect: - name: 'Christmas Day' + name: 'Additional public holiday for Christmas Day' - given: - date: '2016-12-27' + date: '2016-12-26' regions: ["au_nt"] - options: ["observed"] expect: - name: 'Christmas Day' + name: 'Additional public holiday for Christmas Day' - given: date: '2017-01-01' - regions: ["au", "au_qld", "au_nsw", "au_act", "au_vic", "au_sa", "au_wa", "au_nt"] + regions: ["au_qld", "au_nsw", "au_act", "au_vic", "au_wa", "au_nt"] expect: name: "New Year's Day" - -#FIXME This commented test is valid but the current code in the ruby repo won't allow it -# to work. We need to discuss potential solutions but in the meantime I'm taking it out. -# See https://github.com/holidays/definitions/issues/37. -# - given: -# date: '2017-01-01' -# regions: ["au_tas"] -# expect: -# holiday: false - - given: date: '2017-01-02' - regions: ["au", "au_qld", "au_nsw", "au_act", "au_vic", "au_sa", "au_wa", "au_nt"] - options: ["observed"] + regions: ["au_qld", "au_nsw", "au_act", "au_vic", "au_sa", "au_wa", "au_nt"] expect: - name: "New Year's Day" + name: "Additional public holiday for New Year's Day" - given: date: '2017-01-02' regions: ["au_tas"] expect: name: "New Year's Day" + - given: + date: '2022-01-03' + regions: ["au_nsw", "au_vic", "au_act", "au_sa", "au_wa", "au_nt", "au_qld"] + expect: + name: "Additional public holiday for New Year's Day" + - given: + date: '2022-01-01' + regions: ["au_nsw", "au_vic", "au_act", "au_wa", "au_nt", "au_qld"] + expect: + name: "New Year's Day" - given: date: '2017-04-16' regions: ["au_qld"] expect: name: "Easter Sunday" + - given: + date: ['2024-03-31'] + regions: ["au_sa"] + expect: + name: "Easter Sunday" + - given: + date: '2022-04-17' + regions: ["au_wa"] + expect: + name: "Easter Sunday" + - given: + date: '2021-08-02' + regions: ["au_nt"] + expect: + name: "Picnic Day" + - given: + date: '2023-04-09' + regions: ["au_nt"] + expect: + name: "Easter Sunday" diff --git a/be_fr.yaml b/be_fr.yaml index 315c5e48..4fec3512 100644 --- a/be_fr.yaml +++ b/be_fr.yaml @@ -17,10 +17,6 @@ months: regions: ['be_fr'] function: easter(year) function_modifier: 39 - - name: Pentecôte - regions: ['be_fr'] - function: easter(year) - function_modifier: 49 - name: Lundi de Pentecôte regions: ['be_fr'] function: easter(year) @@ -84,12 +80,6 @@ tests: options: ["informal"] expect: name: 'Ascension' - - given: - date: '2007-05-27' - regions: ['be_fr'] - options: ["informal"] - expect: - name: 'Pentecôte' - given: date: '2007-05-28' regions: ['be_fr'] diff --git a/be_nl.yaml b/be_nl.yaml index 45861951..667cb9f3 100644 --- a/be_nl.yaml +++ b/be_nl.yaml @@ -17,10 +17,6 @@ months: regions: [be_nl] function: easter(year) function_modifier: 39 - - name: Pinksteren - regions: [be_nl] - function: easter(year) - function_modifier: 49 - name: Pinkstermaandag regions: [be_nl] function: easter(year) @@ -84,12 +80,6 @@ tests: options: ["informal"] expect: name: 'O.H. Hemelvaart' - - given: - date: '2007-05-27' - regions: ["be_nl"] - options: ["informal"] - expect: - name: 'Pinksteren' - given: date: '2007-05-28' regions: ["be_nl"] diff --git a/cy.yaml b/cy.yaml new file mode 100644 index 00000000..8db43629 --- /dev/null +++ b/cy.yaml @@ -0,0 +1,174 @@ +# Cyprus holiday definitions for the Ruby Holiday gem. +# +# Created: 2023-11-13. +# Sources: + # https://www.officeholidays.com/countries/cyprus/2023 + # https://www.officeholidays.com/countries/cyprus/2024 + # https://en.wikipedia.org/wiki/Public_holidays_in_Cyprus +--- +months: + 0: + - name: Μεγάλη Παρασκευή + regions: [cy] + function: orthodox_easter(year) + function_modifier: -2 + - name: Μεγάλο Σάββατο + regions: [cy] + function: orthodox_easter(year) + function_modifier: -1 + - name: Κυριακή του Πάσχα + regions: [cy] + function: orthodox_easter(year) + - name: Δευτέρα του Πάσχα + regions: [cy] + function: orthodox_easter(year) + function_modifier: 1 + - name: Καθαρά Δευτέρα + regions: [cy] + function: orthodox_easter(year) + function_modifier: -48 + - name: Αγίου Πνεύματος + regions: [cy] + function: orthodox_easter(year) + function_modifier: 50 + 1: + - name: Πρωτοχρονιά + regions: [cy] + mday: 1 + - name: Θεοφάνεια + regions: [cy] + mday: 6 + 3: + - name: Επέτειος της Επανάστασης του 1821 + regions: [cy] + mday: 25 + 4: + - name: Εθνική Ημέρα της Κύπρου + regions: [cy] + mday: 1 + 5: + - name: Πρωτομαγιά + regions: [cy] + mday: 1 + 8: + - name: Κοίμηση της Θεοτόκου + regions: [cy] + mday: 15 + 10: + - name: Ημέρα Ανεξαρτησίας + regions: [cy] + mday: 1 + - name: Επέτειος του Όχι + regions: [cy] + mday: 28 + 12: + - name: Χριστούγεννα + regions: [cy] + mday: 25 + - name: Ημέρα Πυγμαχίας + regions: [cy] + mday: 26 + +tests: + - given: + date: '2023-04-01' + regions: ["cy"] + options: ["informal"] + expect: + name: "Εθνική Ημέρα της Κύπρου" + - given: + date: '2023-10-01' + regions: ["cy"] + options: ["informal"] + expect: + name: "Ημέρα Ανεξαρτησίας" + - given: + date: '2011-01-01' + regions: ["cy"] + options: ["informal"] + expect: + name: "Πρωτοχρονιά" + - given: + date: '2011-01-06' + regions: ["cy"] + options: ["informal"] + expect: + name: "Θεοφάνεια" + - given: + date: '2011-04-22' + regions: ["cy"] + options: ["informal"] + expect: + name: "Μεγάλη Παρασκευή" + - given: + date: '1970-04-25' + regions: ["cy"] + options: ["informal"] + expect: + name: "Μεγάλο Σάββατο" + - given: + date: '1985-04-14' + regions: ["cy"] + options: ["informal"] + expect: + name: "Κυριακή του Πάσχα" + - given: + date: '2011-04-24' + regions: ["cy"] + options: ["informal"] + expect: + name: "Κυριακή του Πάσχα" + - given: + date: '2027-05-02' + regions: ["cy"] + options: ["informal"] + expect: + name: "Κυριακή του Πάσχα" + - given: + date: '2046-04-30' + regions: ["cy"] + options: ["informal"] + expect: + name: "Δευτέρα του Πάσχα" + - given: + date: '2011-05-01' + regions: ["cy"] + options: ["informal"] + expect: + name: "Πρωτομαγιά" + - given: + date: '2011-06-13' + regions: ["cy"] + options: ["informal"] + expect: + name: "Αγίου Πνεύματος" + - given: + date: '2012-06-04' + regions: ["cy"] + options: ["informal"] + expect: + name: "Αγίου Πνεύματος" + - given: + date: '2011-03-07' + regions: ["cy"] + options: ["informal"] + expect: + name: "Καθαρά Δευτέρα" + - given: + date: '2012-02-27' + regions: ["cy"] + options: ["informal"] + expect: + name: "Καθαρά Δευτέρα" + - given: + date: '2011-12-25' + regions: ["cy"] + options: ["informal"] + expect: + name: "Χριστούγεννα" + - given: + date: '2011-12-26' + regions: ["cy"] + options: ["informal"] + expect: + name: "Δεύτερη ημέρα των Χριστουγέννων" diff --git a/dk.yaml b/dk.yaml index 155cf3bb..215bf03e 100644 --- a/dk.yaml +++ b/dk.yaml @@ -13,11 +13,6 @@ months: function: easter(year) function_modifier: -49 type: informal - - name: Palmesøndag - regions: [dk] - function: easter(year) - function_modifier: -7 - type: informal - name: Skærtorsdag regions: [dk] function: easter(year) diff --git a/el.yaml b/el.yaml index 79b30661..d27fdb29 100644 --- a/el.yaml +++ b/el.yaml @@ -34,6 +34,10 @@ months: regions: [el] function: orthodox_easter(year) function_modifier: 50 + - name: Πεντηκοστή + regions: [el] + function: orthodox_easter(year) + function_modifier: 49 1: - name: Πρωτοχρονιά regions: [el] @@ -66,6 +70,18 @@ months: mday: 26 tests: + - given: + date: '2023-06-04' + regions: ["el"] + options: ["informal"] + expect: + name: "Πεντηκοστή" + - given: + date: '2024-06-23' + regions: ["el"] + options: ["informal"] + expect: + name: "Πεντηκοστή" - given: date: '2011-01-01' regions: ["el"] diff --git a/es.yaml b/es.yaml index 4b55ceda..f4323fa9 100644 --- a/es.yaml +++ b/es.yaml @@ -29,6 +29,8 @@ months: regions: [es] mday: 1 observed: to_monday_if_sunday(date) + year_ranges: + - before: 2022 - name: Día de Reyes regions: [es] mday: 6 diff --git a/federal_reserve.yaml b/federal_reserve.yaml index 2a9799ce..b2af0a9d 100644 --- a/federal_reserve.yaml +++ b/federal_reserve.yaml @@ -11,7 +11,7 @@ months: regions: [federal_reserve] mday: 1 observed: to_monday_if_sunday(date) - - name: Birthday of Martin Luther King, Jr + - name: Birthday of Martin Luther King Jr week: 3 wday: 1 regions: [federal_reserve] @@ -67,7 +67,7 @@ tests: regions: ["federal_reserve"] options: ["observed"] expect: - name: "Birthday of Martin Luther King, Jr" + name: "Birthday of Martin Luther King Jr" - given: date: '2012-02-20' regions: ["federal_reserve"] @@ -127,7 +127,7 @@ tests: regions: ["federal_reserve"] options: ["observed"] expect: - name: "Birthday of Martin Luther King, Jr" + name: "Birthday of Martin Luther King Jr" - given: date: '2013-02-18' regions: ["federal_reserve"] @@ -187,7 +187,7 @@ tests: regions: ["federal_reserve"] options: ["observed"] expect: - name: "Birthday of Martin Luther King, Jr" + name: "Birthday of Martin Luther King Jr" - given: date: '2014-02-17' regions: ["federal_reserve"] @@ -247,7 +247,7 @@ tests: regions: ["federal_reserve"] options: ["observed"] expect: - name: "Birthday of Martin Luther King, Jr" + name: "Birthday of Martin Luther King Jr" - given: date: '2015-02-16' regions: ["federal_reserve"] @@ -307,7 +307,7 @@ tests: regions: ["federal_reserve"] options: ["observed"] expect: - name: "Birthday of Martin Luther King, Jr" + name: "Birthday of Martin Luther King Jr" - given: date: '2016-02-15' regions: ["federal_reserve"] diff --git a/gb.yaml b/gb.yaml index d594eba0..38bfefdb 100644 --- a/gb.yaml +++ b/gb.yaml @@ -18,9 +18,6 @@ months: regions: [gb] function: easter(year) function_modifier: -2 - - name: Easter Sunday - regions: [gb] - function: easter(year) - name: Easter Monday regions: [gb_eng, gb_wls, gb_eaw, gb_nir, je, gb_jsy, gg, gb_gsy] function: easter(year) @@ -42,17 +39,36 @@ months: regions: [gb_nir] mday: 17 5: - - name: May Day + - name: Early May Bank Holiday regions: [gb] week: 1 wday: 1 + - name: Bank holiday for the coronation of King Charles III + regions: [gb] + mday: 8 + year_ranges: + - limited: [2023] - name: Liberation Day regions: [je, gb_jsy, gg, gb_gsy] mday: 9 - - name: Bank Holiday + - name: Spring Bank Holiday regions: [gb] week: -1 wday: 1 + year_ranges: + - before: 2021 + - after: 2023 + 6: + - name: Spring Bank Holiday + regions: [gb] + mday: 2 + year_ranges: + - limited: [2022] + - name: Platinum Jubilee Bank Holiday + regions: [gb] + mday: 3 + year_ranges: + - limited: [2022] 7: - name: Tynwald Day regions: [im, gb_iom] @@ -65,7 +81,7 @@ months: regions: [gb_sct] week: 1 wday: 1 - - name: Bank Holiday + - name: Summer Bank Holiday regions: [gb_eng, gb_wls, gb_eaw, gb_nir, je, gb_jsy, gg, gb_gsy] week: -1 wday: 1 @@ -92,10 +108,26 @@ months: regions: [gb] mday: 25 observed: to_monday_if_weekend(date) + year_ranges: + - before: 2021 + - after: 2023 - name: Boxing Day regions: [gb] mday: 26 observed: to_weekday_if_boxing_weekend(date) + year_ranges: + - before: 2021 + - after: 2023 + - name: Christmas Day (substitute day) + regions: [gb] + mday: 27 + year_ranges: + - limited: [2022] + - name: Boxing Day + regions: [gb] + mday: 26 + year_ranges: + - limited: [2022] tests: - given: @@ -105,23 +137,29 @@ tests: expect: name: "Good Friday" - given: - date: '2008-03-23' + date: '2008-05-05' regions: ["gb"] options: ["informal"] expect: - name: "Easter Sunday" + name: "Early May Bank Holiday" - given: - date: '2008-05-05' + date: '2008-05-26' regions: ["gb"] options: ["informal"] expect: - name: "May Day" + name: "Spring Bank Holiday" - given: - date: '2008-05-26' + date: '2022-06-02' regions: ["gb"] options: ["informal"] expect: - name: "Bank Holiday" + name: "Spring Bank Holiday" + - given: + date: '2022-06-03' + regions: ["gb"] + options: ["informal"] + expect: + name: "Platinum Jubilee Bank Holiday" - given: date: '2008-11-05' regions: ["gb"] @@ -134,6 +172,18 @@ tests: options: ["informal"] expect: name: "Christmas Day" + - given: + date: '2022-12-25' + regions: ["gb"] + options: ["informal"] + expect: + holiday: false + - given: + date: '2022-12-27' + regions: ["gb"] + options: ["informal"] + expect: + name: "Christmas Day" - given: date: '2008-12-26' regions: ["gb"] @@ -316,7 +366,7 @@ tests: date: '2008-08-25' regions: ["gb_wls"] expect: - name: "Bank Holiday" + name: "Summer Bank Holiday" - given: date: '2008-03-24' regions: ["gb_eng"] @@ -326,7 +376,7 @@ tests: date: '2008-08-25' regions: ["gb_eng"] expect: - name: "Bank Holiday" + name: "Summer Bank Holiday" - given: date: '2008-03-24' regions: ["gb_nir"] @@ -336,7 +386,7 @@ tests: date: '2008-08-25' regions: ["gb_nir"] expect: - name: "Bank Holiday" + name: "Summer Bank Holiday" - given: date: '2008-03-24' regions: ["gb_eaw"] @@ -346,7 +396,7 @@ tests: date: '2008-08-25' regions: ["gb_eaw"] expect: - name: "Bank Holiday" + name: "Summer Bank Holiday" - given: date: '2008-03-24' regions: ["gb_"] @@ -356,7 +406,7 @@ tests: date: '2008-08-25' regions: ["gb_"] expect: - name: "Bank Holiday" + name: "Summer Bank Holiday" - given: date: '2018-05-09' regions: ["je"] @@ -371,4 +421,4 @@ tests: date: '2018-08-27' regions: ["je"] expect: - name: "Bank Holiday" \ No newline at end of file + name: "Summer Bank Holiday" diff --git a/ie.yaml b/ie.yaml index 793ea3c6..a08564d6 100644 --- a/ie.yaml +++ b/ie.yaml @@ -17,6 +17,11 @@ months: regions: [ie] mday: 1 observed: to_monday_if_weekend(date) + 2: + - name: St Brigid's Day + regions: [ie] + week: 1 + wday: 1 3: - name: St. Patrick's Day regions: [ie] @@ -58,6 +63,16 @@ tests: regions: ["ie"] expect: name: "New Year's Day" + - given: + date: '2023-02-06' + regions: ["ie"] + expect: + name: "St Brigid's Day" + - given: + date: '2025-02-01' + regions: ["ie"] + expect: + name: "St Brigid's Day" - given: date: '2008-03-17' regions: ["ie"] diff --git a/index.yaml b/index.yaml index f0681cec..c9515205 100644 --- a/index.yaml +++ b/index.yaml @@ -13,6 +13,7 @@ defs: CL: ['cl.yaml'] CO: ['co.yaml'] CR: ['cr.yaml'] + CY: ['cy.yaml'] CZ: ['cz.yaml'] DK: ['dk.yaml'] DE: ['de.yaml'] @@ -34,19 +35,24 @@ defs: IT: ['it.yaml'] KR: ['kr.yaml'] LI: ['li.yaml'] + LR: ['lr.yaml'] LT: ['lt.yaml'] MA: ['ma.yaml'] + MM: ['mm.yaml'] MT_MT: ['mt_mt.yaml'] MT_EN: ['mt_en.yaml'] MX: ['mx.yaml', 'north_america_informal.yaml'] + MZ: ['mz.yaml'] NERC: ['nerc.yaml'] NL: ['nl.yaml'] LU: ['lu.yaml'] "NO": ['no.yaml'] NYSE: ['nyse.yaml'] NZ: ['nz.yaml'] + NZ2_Calendar_Dates: ['nz2_calendar_dates.yaml'] PE: ['pe.yaml'] PH: ['ph.yaml'] + PK: ['pk.yaml'] PL: ['pl.yaml'] PT: ['pt.yaml'] RO: ['ro.yaml'] @@ -54,11 +60,13 @@ defs: RS_LA: ['rs_la.yaml'] RU: ['ru.yaml'] SE: ['se.yaml'] + TH: ['th.yaml'] TN: ['tn.yaml'] TR: ['tr.yaml'] US: ['us.yaml', 'north_america_informal.yaml'] United_Nations: ['united_nations.yaml'] UPS: ['ups.yaml'] + UY: ['uy.yaml'] ZA: ['za.yaml'] North_America: ['ca.yaml', 'mx.yaml', 'us.yaml', 'north_america_informal.yaml'] South_America: ['ar.yaml', 'br.yaml', 'cl.yaml', 'co.yaml', 'pe.yaml', 've.yaml'] @@ -71,3 +79,6 @@ defs: SI: ['si.yaml'] SG: ['sg.yaml'] MY: ['my.yaml'] + NA: ['na.yaml'] + NF: ['nf.yaml'] + MU: ['mu.yaml'] diff --git a/lib/validation/error.rb b/lib/validation/error.rb index d3095bef..a8cb1170 100644 --- a/lib/validation/error.rb +++ b/lib/validation/error.rb @@ -5,6 +5,7 @@ class NoMonths < Error ; end class InvalidMonth < Error; end class InvalidMethod < Error; end class InvalidRegions < Error; end + class MissingDateSpecification < Error; end class InvalidCustomMethod < Error; end class InvalidTest < Error; end end diff --git a/lib/validation/month_validator.rb b/lib/validation/month_validator.rb index 505751a4..86cabc8b 100644 --- a/lib/validation/month_validator.rb +++ b/lib/validation/month_validator.rb @@ -16,11 +16,41 @@ def call(months) month_def['regions'].each do |region| raise Errors::InvalidRegions.new("A month must contain at least one region, received: #{months}") if region.nil? || region.empty? end + + # Validate that each holiday has at least one date specification + validate_date_specification!(month_def) end end true end + + private + + def validate_date_specification!(month_def) + has_mday = month_def.key?('mday') && !month_def['mday'].nil? + has_wday = month_def.key?('wday') && !month_def['wday'].nil? + has_week = month_def.key?('week') && !month_def['week'].nil? + has_function = month_def.key?('function') && !month_def['function'].nil? && !month_def['function'].empty? + + holiday_name = month_def['name'] || 'Unknown Holiday' + + # If wday is specified, week must also be specified (and vice versa) + if (has_wday && !has_week) || (!has_wday && has_week) + raise Errors::MissingDateSpecification.new( + "Holiday '#{holiday_name}' with 'wday' must also have 'week' attribute (and vice versa)" + ) + end + + # Must have either mday, function, or both wday AND week + valid_date_spec = has_mday || has_function || (has_wday && has_week) + + unless valid_date_spec + raise Errors::MissingDateSpecification.new( + "Holiday '#{holiday_name}' must have either 'mday', 'function', or both 'wday' and 'week' attributes to specify the date" + ) + end + end end end end diff --git a/lr.yaml b/lr.yaml new file mode 100644 index 00000000..007a399d --- /dev/null +++ b/lr.yaml @@ -0,0 +1,73 @@ +# Liberian holiday definitions for the Ruby Holiday gem. +# +# Updated: 2018-10-31. +# +# Sources: +# - https://www.officeholidays.com/countries/liberia/2018 +# - https://en.wikipedia.org/wiki/Public_holidays_in_Liberia +--- +months: + 1: + - name: New Year's Day + regions: [lr] + mday: 1 + 2: + - name: Armed Forces Day + regions: [lr] + mday: 11 + 3: + - name: J.J. Roberts' Birthday + regions: [lr] + mday: 15 + - name: Decoration Day + regions: [lr] + week: 2 + wday: 3 + 4: + - name: National Redemption Day + regions: [lr] + mday: 12 + - name: Fast and Prayer Day + regions: [lr] + week: 2 + wday: 5 + 5: + - name: National Unification Day + regions: [lr] + mday: 14 + 7: + - name: Independence Day + regions: [lr] + mday: 26 + 8: + - name: Flag Day + regions: [lr] + mday: 24 + 11: + - name: William Tubman's Birthday + regions: [lr] + mday: 29 + - name: National Thanksgiving Day + regions: [lr] + week: 1 + wday: 4 + 12: + - name: Christmas Day + regions: [lr] + mday: 25 +tests: + - given: + date: ['2018-03-14', '2019-03-13'] + regions: ['lr'] + expect: + name: 'Decoration Day' + - given: + date: ['2018-04-13', '2020-04-10'] + regions: ['lr'] + expect: + name: 'Fast and Prayer Day' + - given: + date: ['2018-11-01', '2019-11-07'] + regions: ['lr'] + expect: + name: 'National Thanksgiving Day' diff --git a/mm.yaml b/mm.yaml new file mode 100644 index 00000000..eadf7ad0 --- /dev/null +++ b/mm.yaml @@ -0,0 +1,248 @@ +# Myanmar holiday (incomplete)definitions for the Ruby Holiday gem. +# +# Updated: 2020-01-06. +# Some dates in Islamic Calendar are missing. +# Sources: +# - Sourced from client (KBZ BANK) via Alex Holder +# https://docs.google.com/spreadsheets/d/1S6JzcjLsH9ZeQXEh5x724aHIsuJvdK62qLM7yS-TTQY/edit?usp=sharing +--- +months: + 1: + - name: New Year's Day + regions: [mm] + mday: 1 + year_ranges: + - limited: 2019 + - name: Independence Day + regions: [mm] + mday: 4 + - name: Substitute Day + regions: [mm] + mday: 6 + year_ranges: + - limited: 2020 + - name: Kayin New Year's Day + regions: [mm] + mday: 13 + year_ranges: + - limited: 2019 + 2: + - name: Union Day + regions: [mm] + mday: 12 + 3: + - name: Peasants Day + regions: [mm] + mday: 2 + - name: Full Moon Day of Taboung + regions: [mm] + mday: 8 + year_ranges: + - limited: 2020 + - name: Substitute Day + regions: [mm] + mday: 9 + year_ranges: + - limited: 2020 + - name: Tabaung Full Moon Day + regions: [mm] + mday: 20 + year_ranges: + - limited: 2019 + - name: Armed Forces Day + regions: [mm] + mday: 27 + 4: + - name: Myanmar New Year Holiday + regions: [mm] + mday: 10 + year_ranges: + - limited: 2020 + - name: Myanmar New Year Holiday + regions: [mm] + mday: 11 + year_ranges: + - limited: 2020 + - name: Maha Thingyan (Water Festival) + regions: [mm] + mday: 12 + year_ranges: + - limited: 2020 + - name: Thingyan Eve + regions: [mm] + mday: 13 + year_ranges: + - limited: 2019 + - name: Maha Thingyan (Water Festival) + regions: [mm] + mday: 13 + year_ranges: + - limited: 2020 + - name: Thingyan (Start of Water Festival) + regions: [mm] + mday: 14 + year_ranges: + - limited: 2019 + - name: Maha Thingyan (Water Festival) + regions: [mm] + mday: 14 + year_ranges: + - limited: 2020 + - name: Water Festival Day + regions: [mm] + mday: 15 + year_ranges: + - limited: 2019 + - name: Maha Thingyan (Water Festival) + regions: [mm] + mday: 15 + year_ranges: + - limited: 2020 + - name: Water Festival Day + regions: [mm] + mday: 16 + year_ranges: + - limited: 2019 + - name: Maha Thingyan (Water Festival) + regions: [mm] + mday: 16 + year_ranges: + - limited: 2020 + - name: Myanmar New Year Day + regions: [mm] + mday: 17 + year_ranges: + - limited: 2019 + - name: Myanmar New Year Holiday + regions: [mm] + mday: 17 + year_ranges: + - limited: 2020 + 5: + - name: Labor Day / May Day + regions: [mm] + mday: 1 + - name: Full Moon Day of Kasong + regions: [mm] + mday: 6 + year_ranges: + - limited: 2020 + - name: Kasone Full Moon Day + regions: [mm] + mday: 18 + year_ranges: + - limited: 2019 + 6: + - name: Warso Full Moon Day + regions: [mm] + mday: 16 + year_ranges: + - limited: 2019 + - name: Martyrs' Day + regions: [mm] + mday: 19 + - name: Substitute Day + regions: [mm] + mday: 20 + year_ranges: + - limited: 2020 + 7: + - name: Full Moon Day of Waso (Beginning of Buddhist Lent) + regions: [mm] + mday: 3 + year_ranges: + - limited: 2020 + 10: + - name: Buddhist Lent Holiday + regions: [mm] + mday: 12 + year_ranges: + - limited: 2019 + - name: Thadingyut Full Moon Day + regions: [mm] + mday: 13 + year_ranges: + - limited: 2019 + - name: Buddhist Lent Holiday + regions: [mm] + mday: 14 + year_ranges: + - limited: 2019 + - name: Thadingyut Holiday + regions: [mm] + mday: 29 + year_ranges: + - limited: 2020 + - name: Thadingyut Holiday + regions: [mm] + mday: 30 + year_ranges: + - limited: 2020 + - name: Full Moon Day of Thadingyut (End of Buddhist Lent) + regions: [mm] + mday: 31 + year_ranges: + - limited: 2020 + 11: + - name: Thadingyut Holiday + regions: [mm] + mday: 1 + year_ranges: + - limited: 2020 + - name: Thadingyut Holiday + regions: [mm] + mday: 2 + year_ranges: + - limited: 2020 + - name: Tazaung Daing Holiday + regions: [mm] + mday: 10 + year_ranges: + - limited: 2019 + - name: Tazaung Daing Full Moon Day + regions: [mm] + mday: 11 + year_ranges: + - limited: 2019 + - name: National Day + regions: [mm] + mday: 21 + year_ranges: + - limited: 2019 + - name: Dasaung Taing Holiday + regions: [mm] + mday: 27 + year_ranges: + - limited: 2020 + - name: Dasaung Taing Holiday + regions: [mm] + mday: 28 + year_ranges: + - limited: 2020 + - name: Dasaung Taing Full Mon Day + regions: [mm] + mday: 29 + year_ranges: + - limited: 2020 + - name: Dasaung Taing Holiday + regions: [mm] + mday: 30 + year_ranges: + - limited: 2020 + 12: + - name: National Day + regions: [mm] + mday: 9 + year_ranges: + - limited: 2020 + - name: Christmas Day + regions: [mm] + mday: 25 + - name: Kayin New Year Day + regions: [mm] + mday: 26 + year_ranges: + - limited: 2019 + - name: New Year Eve + regions: [mm] + mday: 31 diff --git a/mu.yaml b/mu.yaml new file mode 100644 index 00000000..2f12eddd --- /dev/null +++ b/mu.yaml @@ -0,0 +1,219 @@ +# Mauritius holiday (incomplete)definitions for the Ruby Holiday gem. +# +# Updated: 2021-06-02. +# Some dates in Islamic Calendar (Eid-Ul-Fitr) are missing. +# Sources: +# - Sourced from https://www.officeholidays.com/countries/mauritius/2021 , https://www.officeholidays.com/countries/mauritius/2022 +--- +months: + 1: + - name: New Year's Day + regions: [mu] + mday: 1 + - name: New Year's Holiday + regions: [mu] + mday: 2 + - name: Thaipoosam Cavadee + regions: [mu] + mday: 25 + year_ranges: + - limited: [2024] + - name: Thaipoosam Cavadee + regions: [mu] + mday: 28 + year_ranges: + - limited: [2021] + - name: Thaipoosam Cavadee + regions: [mu] + mday: 18 + year_ranges: + - limited: [2022] + - name: Chinese Spring Festival + regions: [mu] + mday: 29 + year_ranges: + - limited: [2025] + 2: + - name: Abolition of Slavery + regions: [mu] + mday: 1 + - name: Chinese Spring Festival + regions: [mu] + mday: 10 + year_ranges: + - limited: [2024] + - name: Chinese Spring Festival + regions: [mu] + mday: 01 + year_ranges: + - limited: [2022] + - name: Chinese Spring Festival + regions: [mu] + mday: 12 + year_ranges: + - limited: [2021] + - name: Thaipoosam Cavadee + regions: [mu] + mday: 11 + year_ranges: + - limited: [2025] + - name: Thaipoosam Cavadee + regions: [mu] + mday: 01 + year_ranges: + - limited: [2026] + - name: Maha Shivaratree + regions: [mu] + mday: 15 + year_ranges: + - limited: [2026] + 3: + - name: Maha Shivaratree + regions: [mu] + mday: 8 + year_ranges: + - limited: [2024] + - name: Ugaadi + regions: [mu] + mday: 30 + year_ranges: + - limited: [2025] + - name: Ugaadi + regions: [mu] + mday: 20 + year_ranges: + - limited: [2026] + - name: Maha Shivaratree + regions: [mu] + mday: 1 + year_ranges: + - limited: [2022] + - name: Maha Shivaratree + regions: [mu] + mday: 11 + year_ranges: + - limited: [2021] + - name: Independence and Republic Day + regions: [mu] + mday: 12 + - name: Eid-Ul-Fitr + regions: [mu] + mday: 31 + year_ranges: + - limited: [2025] + 4: + - name: Ugaadi + regions: [mu] + mday: 9 + year_ranges: + - limited: [2024] + - name: Ougadi + regions: [mu] + mday: 2 + year_ranges: + - limited: [2022] + - name: Ougadi + regions: [mu] + mday: 13 + year_ranges: + - limited: [2021] + 5: + - name: Labour Day + regions: [mu] + mday: 1 + 8: + - name: Assumption Day + regions: [mu] + mday: 15 + year_ranges: + - limited: [2022] + - name: Ganesh Chaturthi + regions: [mu] + mday: 28 + year_ranges: + - limited: [2025] + 9: + - name: Ganesh Chaturthi + regions: [mu] + mday: 15 + year_ranges: + - limited: [2026] + - name: Ganesh Chaturthi + regions: [mu] + mday: 8 + year_ranges: + - limited: [2024] + - name: Ganesh Chaturthi + regions: [mu] + mday: 11 + year_ranges: + - limited: [2021] + - name: Ganesh Chaturthi + regions: [mu] + mday: 1 + year_ranges: + - limited: [2022] + 10: + - name: Diwali + regions: [mu] + mday: 20 + year_ranges: + - limited: [2025] + - name: Diwali + regions: [mu] + mday: 31 + year_ranges: + - limited: [2024] + - name: Diwali + regions: [mu] + mday: 24 + year_ranges: + - limited: [2022] + 11: + - name: Diwali + regions: [mu] + mday: 8 + year_ranges: + - limited: [2026] + - name: All Saints' Day + regions: [mu] + mday: 1 + year_ranges: + - limited: [2025] + - name: All Saints' Day + regions: [mu] + mday: 1 + - name: Arrival of Indentured Labourers + regions: [mu] + mday: 2 + - name: Diwali + regions: [mu] + mday: 4 + year_ranges: + - limited: [2021] + 12: + - name: Christmas Day + regions: [mu] + mday: 25 + +tests: + - given: + date: '2012-01-01' + regions: ["mu"] + expect: + name: "New Year's Day" + - given: + date: '2022-02-01' + regions: ["mu"] + expect: + name: 'Abolition of Slavery' + - given: + date: '2023-05-01' + regions: ["mu"] + expect: + name: 'Labour Day' + - given: + date: '2017-12-25' + regions: ["mu"] + expect: + name: 'Christmas Day' diff --git a/mx.yaml b/mx.yaml index ed7feff7..7c8fce43 100644 --- a/mx.yaml +++ b/mx.yaml @@ -9,9 +9,6 @@ months: - name: Año nuevo regions: [mx] mday: 1 - - name: Dia de los Santos Reyes - regions: [mx] - mday: 6 2: - name: Día de la Constitución week: 1 @@ -89,9 +86,6 @@ months: - name: Navidad regions: [mx] mday: 25 - - name: Los Santos Inocentes - regions: [mx] - mday: 28 tests: - given: diff --git a/my.yaml b/my.yaml index d73a2dcf..048a220c 100644 --- a/my.yaml +++ b/my.yaml @@ -22,7 +22,8 @@ months: 6: - name: Agong's Birthday regions: [my] - mday: 4 + week: 1 + wday: 1 observed: to_weekday_if_weekend(date) 8: - name: Independence Day @@ -33,7 +34,6 @@ months: - name: Malaysia Day regions: [my] mday: 16 - observed: to_weekday_if_weekend(date) 12: - name: Christmas Day regions: [my] diff --git a/mz.yaml b/mz.yaml new file mode 100644 index 00000000..e8298285 --- /dev/null +++ b/mz.yaml @@ -0,0 +1,95 @@ +# Mozambique holiday definitions for the Holidays gem! + +# Source: +# http://www.officeholidays.com/countries/mozambique/2017.php + +months: + 1: + - name: New Year's Day + regions: [mz] + mday: 1 + observed: to_monday_if_weekend(date) + 2: + - name: Heroes' Day + regions: [mz] + mday: 3 + 4: + - name: Women's Day + regions: [mz] + mday: 7 + 5: + - name: Worker's Day + regions: [mz] + mday: 1 + 6: + - name: Independence Day + regions: [mz] + mday: 25 + 9: + - name: Victory Day + regions: [mz] + mday: 7 + - name: Revolution Day + regions: [mz] + mday: 25 + 10: + - name: Day of Peace and Reconciliation + regions: [mz] + mday: 4 + 12: + - name: Family Day + regions: [mz] + mday: 25 + +tests: + - given: + date: '2017-01-01' + regions: ["mz"] + expect: + name: "New Year's Day" + - given: + date: '2017-01-02' + regions: ["mz"] + options: ["observed"] + expect: + name: "New Year's Day" + - given: + date: '2017-02-03' + regions: ["mz"] + expect: + name: "Heroes' Day" + - given: + date: '2017-04-07' + regions: ["mz"] + expect: + name: "Women's Day" + - given: + date: '2017-05-01' + regions: ["mz"] + expect: + name: "Worker's Day" + - given: + date: '2017-06-25' + regions: ["mz"] + expect: + name: "Independence Day" + - given: + date: '2017-09-07' + regions: ["mz"] + expect: + name: "Victory Day" + - given: + date: '2017-09-25' + regions: ["mz"] + expect: + name: "Revolution Day" + - given: + date: '2017-10-04' + regions: ["mz"] + expect: + name: "Day of Peace and Reconciliation" + - given: + date: '2017-12-25' + regions: ["mz"] + expect: + name: "Family Day" diff --git a/na.yaml b/na.yaml new file mode 100644 index 00000000..04fe8bf2 --- /dev/null +++ b/na.yaml @@ -0,0 +1,102 @@ +# Namibia holiday definitions for the Ruby Holiday gem. +# +# +# http://www.gov.na/holidays - shows list of days recognised as public holidays but dates haven't been updated since 2014 +# can also look at https://publicholidays.africa/namibia/2018-dates/ +# future dates at https://publicholidays.africa/namibia/2019-dates/ +# https://www.timeanddate.com/holidays/namibia/ - shows current dates +# Note that Ascension Day as that is Easter Sunday + 39 days which in 2017 landed on the same day as Africa Day - https://en.wikipedia.org/wiki/Public_holidays_in_Namibia +months: + 0: + - name: Good Friday + regions: [na] + # calculates Easter Sunday + function: easter(year) + # goes 2 days back from Easter Sunday + function_modifier: -2 + - name: Easter Monday + regions: [na] + # calculates Easter Sunday + function: easter(year) + # goes 1 day forward from Easter Sunday + function_modifier: 1 + - name: Ascension Day + regions: [na] + function: easter(year) + function_modifier: 39 + 1: + - name: New Years Days + regions: [na] + mday: 1 + 3: + - name: Independence Day + regions: [na] + mday: 21 + 5: + - name: Worker's Day + regions: [na] + mday: 1 + - name: Cassinga Day + regions: [na] + mday: 4 + - name: Africa Day + regions: [na] + mday: 25 + 8: + - name: Heroes' Day + regions: [na] + mday: 26 + observed: to_monday_if_weekend(date) + 12: + - name: International Human Rights Day + regions: [na] + mday: 10 + - name: Christmas Day + regions: [na] + mday: 25 + - name: Family Day + regions: [na] + mday: 26 + +tests: + - given: + date: '2018-1-1' + regions: [na] + expect: + name: New Years Days + - given: + date: '2018-03-30' + regions: [na] + expect: + name: Good Friday + - given: + date: '2018-04-02' + regions: [na] + expect: + name: Easter Monday + - given: + date: '2018-05-10' + regions: [na] + expect: + name: Ascension Day + - given: + date: '2018-08-27' + regions: [na] + options: ["observed"] + expect: + name: Heroes' Day + - given: + date: '2019-04-22' + regions: [na] + expect: + name: Easter Monday + - given: + date: '2019-05-30' + regions: [na] + expect: + name: Ascension Day + - given: + date: '2019-08-26' + regions: [na] + expect: + name: Heroes' Day diff --git a/nf.yaml b/nf.yaml new file mode 100644 index 00000000..72adfdc0 --- /dev/null +++ b/nf.yaml @@ -0,0 +1,119 @@ +# Liberian holiday definitions for the Ruby Holiday gem. +# +# Updated: 2018-11-21. +# +# Sources: +# - https://publicholidays.asia/norfolk-island/2018-dates/ +# - https://publicholidays.asia/norfolk-island/2019-dates/ +# - https://publicholidays.asia/norfolk-island/2020-dates/ +# - https://en.wikipedia.org/wiki/Public_holidays_in_Norfolk_Island +# - +--- +months: + 0: + - name: Good Friday + regions: [nf] + function: easter(year) + function_modifier: -2 + - name: Easter Monday + regions: [nf] + function: easter(year) + function_modifier: +1 + 1: + - name: New Year's Day + regions: [nf] + mday: 1 + - name: (additional day New Year's Day) + regions: [nf] + mday: 1 + observed: to_monday_if_weekend(date) + - name: Australia Day + regions: [nf] + mday: 26 + observed: to_monday_if_weekend(date) + 3: + - name: Foundation Day + regions: [nf] + mday: 6 + - name: (additional day Foundation Day) + regions: [nf] + mday: 6 + observed: to_monday_if_weekend(date) + 4: + - name: Anzac Day + regions: [nf] + mday: 25 + 6: + - name: Bounty Day + regions: [nf] + mday: 8 + observed: to_monday_if_weekend(date) + - name: Queen's Birthday + regions: [nf] + function: monday_after_second_saturday(year) + 10: + - name: Norfolk Island Agricultural Show + regions: [nf] + week: 2 + wday: 1 + 11: + - name: Thanksgiving Day + regions: [nf] + week: 5 + wday: 3 + 12: + - name: Christmas Day + regions: [nf] + mday: 25 + - name: (additional day Christmas Day) + regions: [nf] + mday: 25 + function: to_tuesday_if_sunday(date) + - name: Boxing Day + regions: [nf] + mday: 26 + +methods: + monday_after_second_saturday: + arguments: year + source: | + second_sat_in_jun = Date.civil(year, 6, Holidays::Factory::DateCalculator.day_of_month_calculator.call(year, 6, 2, :saturday)) + second_sat_in_jun + 2 + to_tuesday_if_sunday: + arguments: date + source: | + if [6,0].include?(date.wday) + date += 2 + date + else + nil + end + +tests: + - given: + date: ['2018-03-30', '2019-04-19', '2020-04-10'] + regions: ['nf'] + expect: + name: 'Good Friday' + - given: + date: ['2018-04-02', '2019-04-22', '2020-04-13'] + regions: ['nf'] + expect: + name: 'Easter Monday' + - given: + date: ['2018-06-11', '2019-06-10', '2020-06-15'] + regions: ['nf'] + expect: + name: "Queen's Birthday" + - given: + date: ['2019-01-28', '2020-01-27'] + regions: ['nf'] + options: ["observed"] + expect: + name: "Australia Day" + - given: + date: ['2019-12-26', '2020-12-28'] + regions: ['nf'] + options: ["observed"] + expect: + name: "Boxing Day" diff --git a/no.yaml b/no.yaml index 66f640a9..7718f164 100644 --- a/no.yaml +++ b/no.yaml @@ -12,10 +12,6 @@ months: function: easter(year) function_modifier: -49 type: informal - - name: Palmesøndag - regions: ["no"] - function: easter(year) - function_modifier: -7 - name: Skjærtorsdag regions: ["no"] function: easter(year) @@ -119,12 +115,6 @@ tests: options: ["informal"] expect: name: "Fastelavn" - - given: - date: '2010-03-28' - regions: ["no"] - options: ["informal"] - expect: - name: "Palmesøndag" - given: date: '2010-04-01' regions: ["no"] diff --git a/nyse.yaml b/nyse.yaml index 83b1e7ce..afe0e470 100644 --- a/nyse.yaml +++ b/nyse.yaml @@ -19,7 +19,7 @@ months: regions: [nyse] mday: 1 observed: to_monday_if_sunday(date) - - name: Martin Luther King, Jr. Day + - name: Martin Luther King Jr. Day week: 3 regions: [nyse] wday: 1 @@ -70,7 +70,7 @@ tests: date: '2008-01-21' regions: ["nyse"] expect: - name: "Martin Luther King, Jr. Day" + name: "Martin Luther King Jr. Day" - given: date: '2008-02-18' regions: ["nyse"] diff --git a/nz.yaml b/nz.yaml index c9eae5a2..39504fba 100644 --- a/nz.yaml +++ b/nz.yaml @@ -66,11 +66,19 @@ months: regions: [nz] week: 1 wday: 1 + - name: Matariki Holiday + regions: [nz] + function: matariki_holiday(year) 9: - name: Dominion Day regions: [nz_sc] week: 4 wday: 1 + - name: Day of mourning for Queen Elizabeth II + regions: [nz] + mday: 26 + year_ranges: + - limited: 2022 10: - name: Hawke's bay Anniversary Day regions: [nz_hb] @@ -271,3 +279,70 @@ methods: arguments: date source: | date + 7 + matariki_holiday: + arguments: year + source: | + case year + when 2022 + Date.civil(2022, 6, 24) + when 2023 + Date.civil(2023, 7, 14) + when 2024 + Date.civil(2024, 6, 28) + when 2025 + Date.civil(2025, 6, 20) + when 2026 + Date.civil(2026, 7, 10) + when 2027 + Date.civil(2027, 6, 25) + when 2028 + Date.civil(2028, 7, 14) + when 2029 + Date.civil(2029, 7, 6) + when 2030 + Date.civil(2030, 6, 21) + when 2031 + Date.civil(2031, 7, 11) + when 2032 + Date.civil(2032, 7, 2) + when 2033 + Date.civil(2033, 6, 24) + when 2034 + Date.civil(2034, 7, 7) + when 2035 + Date.civil(2035, 6, 29) + when 2036 + Date.civil(2036, 7, 21) + when 2037 + Date.civil(2037, 7, 10) + when 2038 + Date.civil(2038, 6, 25) + when 2039 + Date.civil(2039, 7, 15) + when 2040 + Date.civil(2040, 7, 6) + when 2041 + Date.civil(2041, 7, 19) + when 2042 + Date.civil(2042, 7, 11) + when 2043 + Date.civil(2043, 7, 3) + when 2044 + Date.civil(2044, 6, 24) + when 2045 + Date.civil(2045, 7, 7) + when 2046 + Date.civil(2046, 6, 29) + when 2047 + Date.civil(2047, 7, 19) + when 2048 + Date.civil(2048, 7, 3) + when 2049 + Date.civil(2049, 6, 25) + when 2050 + Date.civil(2050, 7, 15) + when 2051 + Date.civil(2051, 6, 30) + when 2052 + Date.civil(2052, 6, 25) + end diff --git a/nz2_calendar_dates.yaml b/nz2_calendar_dates.yaml new file mode 100644 index 00000000..c721fb77 --- /dev/null +++ b/nz2_calendar_dates.yaml @@ -0,0 +1,196 @@ +# New Zealand holiday definitions. Two options, paid as per the 'week day' or this paid on the specific calendar day +# Updated: 2010-03-28. +# Sources: +# - http://en.wikipedia.org/wiki/Public_holidays_in_New_Zealand +--- +months: + 0: + - name: Good Friday + regions: [nz2_calendar_dates] + function: easter(year) + function_modifier: -2 + - name: Easter Monday + regions: [nz2_calendar_dates] + function: easter(year) + function_modifier: 1 + 1: + - name: New Year's Day + regions: [nz2_calendar_dates] + mday: 1 + - name: Day after New Year's Day + regions: [nz2_calendar_dates] + mday: 2 + 2: + - name: Waitangi Day + regions: [nz2_calendar_dates] + mday: 6 + 4: + - name: ANZAC Day + regions: [nz2_calendar_dates] + mday: 25 + 6: + - name: Queen's Birthday + regions: [nz2_calendar_dates] + week: 1 + wday: 1 + - name: Matariki Holiday + regions: [nz2_calendar_dates] + function: matariki_holiday(year) + 9: + - name: Day of mourning for Queen Elizabeth II + regions: [nz2_calendar_dates] + mday: 26 + year_ranges: + - limited: 2022 + 10: + - name: Labour Day + regions: [nz2_calendar_dates] + week: 4 + wday: 1 + 12: + - name: Christmas Day + regions: [nz2_calendar_dates] + mday: 25 + - name: Boxing Day + regions: [nz2_calendar_dates] + mday: 26 + +tests: + - given: + date: '2007-01-01' + regions: ["nz2_calendar_dates"] + options: ["informal"] + expect: + name: "New Year's Day" + - given: + date: '2007-01-02' + regions: ["nz2_calendar_dates"] + options: ["informal"] + expect: + name: "Day after New Year's Day" + - given: + date: '2007-02-06' + regions: ["nz2_calendar_dates"] + options: ["informal"] + expect: + name: "Waitangi Day" + - given: + date: '2007-04-06' + regions: ["nz2_calendar_dates"] + options: ["informal"] + expect: + name: "Good Friday" + - given: + date: '2007-04-09' + regions: ["nz2_calendar_dates"] + options: ["informal"] + expect: + name: "Easter Monday" + - given: + date: '2007-04-25' + regions: ["nz2_calendar_dates"] + options: ["informal"] + expect: + name: "ANZAC Day" + - given: + date: '2007-12-25' + regions: ["nz2_calendar_dates"] + options: ["informal"] + expect: + name: "Christmas Day" + - given: + date: '2007-12-26' + regions: ["nz2_calendar_dates"] + options: ["informal"] + expect: + name: "Boxing Day" + - given: + date: '2015-04-25' + regions: ["nz2_calendar_dates"] + expect: + name: "ANZAC Day" + - given: + date: '2016-04-25' + regions: ["nz2_calendar_dates"] + expect: + name: "ANZAC Day" + - given: + date: '2015-02-06' + regions: ["nz2_calendar_dates"] + expect: + name: "Waitangi Day" + - given: + date: '2016-02-06' + regions: ["nz2_calendar_dates"] + expect: + name: "Waitangi Day" + +methods: + matariki_holiday: + arguments: year + source: | + case year + when 2022 + Date.civil(2022, 6, 24) + when 2023 + Date.civil(2023, 7, 14) + when 2024 + Date.civil(2024, 6, 28) + when 2025 + Date.civil(2025, 6, 20) + when 2026 + Date.civil(2026, 7, 10) + when 2027 + Date.civil(2027, 6, 25) + when 2028 + Date.civil(2028, 7, 14) + when 2029 + Date.civil(2029, 7, 6) + when 2030 + Date.civil(2030, 6, 21) + when 2031 + Date.civil(2031, 7, 11) + when 2032 + Date.civil(2032, 7, 2) + when 2033 + Date.civil(2033, 6, 24) + when 2034 + Date.civil(2034, 7, 7) + when 2035 + Date.civil(2035, 6, 29) + when 2036 + Date.civil(2036, 7, 21) + when 2037 + Date.civil(2037, 7, 10) + when 2038 + Date.civil(2038, 6, 25) + when 2039 + Date.civil(2039, 7, 15) + when 2040 + Date.civil(2040, 7, 6) + when 2041 + Date.civil(2041, 7, 19) + when 2042 + Date.civil(2042, 7, 11) + when 2043 + Date.civil(2043, 7, 3) + when 2044 + Date.civil(2044, 6, 24) + when 2045 + Date.civil(2045, 7, 7) + when 2046 + Date.civil(2046, 6, 29) + when 2047 + Date.civil(2047, 7, 19) + when 2048 + Date.civil(2048, 7, 3) + when 2049 + Date.civil(2049, 6, 25) + when 2050 + Date.civil(2050, 7, 15) + when 2051 + Date.civil(2051, 6, 30) + when 2052 + Date.civil(2052, 6, 25) + end + \ No newline at end of file diff --git a/pk.yaml b/pk.yaml new file mode 100644 index 00000000..63bb4fd9 --- /dev/null +++ b/pk.yaml @@ -0,0 +1,107 @@ +# Pakistan holiday definitions for the Ruby Holiday gem. +# +# https://trello-attachments.s3.amazonaws.com/561af80c433ec5f6175b74ba/59b1156ea7e691f048c08b2b/d5c0513eca7d33141d76615b15d1d58b/Public_holidays_2017_(1).pdf +# Excluded holidays that are dependent on the moon appearing, and holidays that are only for Christians. +# +# https://en.wikipedia.org/wiki/Kashmir_Solidarity_Day +# https://en.wikipedia.org/wiki/Pakistan_Day +# https://www.timeanddate.com/holidays/pakistan/labour-day +# https://en.wikipedia.org/wiki/Independence_Day_(Pakistan) + +months: + 2: + - name: Kashmir Day + regions: [pk] + mday: 5 + 3: + - name: Pakistan Day + regions: [pk] + mday: 23 + 5: + - name: Labour Day + regions: [pk] + mday: 1 + 8: + - name: Independence Day + regions: [pk] + mday: 14 + 12: + - name: Quaid-i-Azam Day + regions: [pk] + mday: 25 +tests: + - given: + date: '2017-02-05' + regions: ["pk"] + expect: + name: 'Kashmir Day' + - given: + date: '2018-02-05' + regions: ["pk"] + expect: + name: 'Kashmir Day' + - given: + date: '2019-02-05' + regions: ["pk"] + expect: + name: 'Kashmir Day' + - given: + date: '2017-03-23' + regions: ["pk"] + expect: + name: 'Pakistan Day' + - given: + date: '2018-03-23' + regions: ["pk"] + expect: + name: 'Pakistan Day' + - given: + date: '2019-03-23' + regions: ["pk"] + expect: + name: 'Pakistan Day' + - given: + date: '2017-05-01' + regions: ["pk"] + expect: + name: 'Labour Day' + - given: + date: '2018-05-01' + regions: ["pk"] + expect: + name: 'Labour Day' + - given: + date: '2019-05-01' + regions: ["pk"] + expect: + name: 'Labour Day' + - given: + date: '2017-08-14' + regions: ["pk"] + expect: + name: 'Independence Day' + - given: + date: '2018-08-14' + regions: ["pk"] + expect: + name: 'Independence Day' + - given: + date: '2019-08-14' + regions: ["pk"] + expect: + name: 'Independence Day' + - given: + date: '2017-12-25' + regions: ["pk"] + expect: + name: 'Quaid-i-Azam Day' + - given: + date: '2018-12-25' + regions: ["pk"] + expect: + name: 'Quaid-i-Azam Day' + - given: + date: '2019-12-25' + regions: ["pk"] + expect: + name: 'Quaid-i-Azam Day' \ No newline at end of file diff --git a/sg.yaml b/sg.yaml index c1e5b055..e26a2653 100644 --- a/sg.yaml +++ b/sg.yaml @@ -1,10 +1,8 @@ # Singapore holiday definitions for the Holidays gem! -# Days not included in the definitions (yet): +# Included in definitions but only till 2026: # Vesak Day (falls on the first full moon in May) -# Lunar New Year (falls on the first day of the Lunar Calendar) # Hari Raya Puasa and Hari Raya Haji (based on moon sightings, Islamic Calendar) -# Deepavali (15th Day of September or October, based on the Hindu Calendar) # Source: # http://publicholidays.sg/ @@ -15,6 +13,31 @@ months: regions: [sg] function: easter(year) function_modifier: -2 + - name: Chinese New Year + regions: [sg] + function: cn_new_lunar_day(year) + observed: to_monday_if_sunday(date) + - name: The second day of Chinese New Year + regions: [sg] + function: cn_new_lunar_day(year) + function_modifier: 1 + observed: to_monday_if_sunday(date) + - name: Deepavali + regions: [sg] + function: deepavali(year) + observed: to_monday_if_sunday(date) + - name: Hari Raya Puasa + regions: [sg] + function: hari_raya_puasa(year) + observed: to_monday_if_sunday(date) + - name: Hari Raya Haji + regions: [sg] + function: hari_raya_haji(year) + observed: to_monday_if_sunday(date) + - name: Vesak Day + regions: [sg] + function: vesak_day(year) + observed: to_monday_if_sunday(date) 1: - name: New Year's Day regions: [sg] @@ -37,13 +60,140 @@ months: - name: National Day regions: [sg] mday: 9 - observed: to_weekday_if_weekend(date) 12: - name: Christmas Day regions: [sg] mday: 25 observed: to_weekday_if_weekend(date) +methods: + cn_new_lunar_day: + arguments: year + source: | + month_day = case year + when 1930, 1949, 1987, 2025, 2063, 2082, 2101, 2112, 2131, 2150, 2207, 2245, 2253, 2283, 2321 + [1, 29] + when 1931, 1950, 1969, 1988, 2007, 2026, 2045, 2083, 2091, 2102, 2121, 2159, 2197, 2208, 2216, 2227, 2246, 2265, 2303, 2322, 2341, 2379 + [2, 17] + when 1932, 1951, 1970, 1989, 2027, 2046, 2114, 2179, 2198, 2209, 2247, 2266, 2304, 2323, 2342, 2361, 2399 + [2, 6] + when 1933, 2009, 2028, 2047, 2066, 2085, 2115, 2161, 2199, 2210, 2229, 2267, 2305, 2316, 2324, 2335, 2381 + [1, 26] + when 1934, 1953, 2037, 2048, 2067, 2086, 2105, 2116, 2181, 2189, 2211, 2257, 2268, 2306, 2325, 2336 + [2, 14] + when 1935, 1943, 1992, 2038, 2106, 2144, 2201, 2212, 2258, 2296, 2307, 2326, 2364 + [2, 4] + when 1936, 1955, 2001, 2039, 2058, 2088, 2107, 2164, 2183, 2221, 2259, 2278, 2308, 2327, 2373 + [1, 24] + when 1937, 1975, 2032, 2040, 2051, 2070, 2108, 2127, 2146, 2165, 2252, 2260, 2271, 2290, 2309, 2328, 2347, 2366 + [2, 11] + when 1938, 1957, 1976, 1995, 2014, 2033, 2071, 2109, 2128, 2185, 2272, 2291, 2329, 2348, 2367, 2386 + [1, 31] + when 1939, 1996, 2015, 2053, 2072, 2110, 2129, 2292, 2330, 2368, 2387 + [2, 19] + when 1940, 1959, 2016, 2035, 2081, 2130, 2149, 2187, 2206, 2225, 2236, 2255, 2312, 2350, 2358, 2369 + [2, 8] + when 1941, 1952, 1971, 1990, 2074, 2093, 2123, 2142, 2180, 2248, 2294, 2343, 2351, 2362 + [1, 27] + when 1942, 1961, 1972, 1991, 2056, 2075, 2094, 2124, 2143, 2200, 2276, 2295, 2344, 2363 + [2, 15] + when 1944, 1963, 1982, 2020, 2096, 2134, 2153, 2172, 2191, 2202, 2240, 2286, 2354, 2392 + [1, 25] + when 1945, 1964, 1983, 2010, 2029, 2162, 2192, 2230, 2249, 2317, 2382 + [2, 13] + when 1946, 2003, 2022, 2041, 2052, 2098, 2147, 2155, 2166, 2223, 2242, 2261, 2299, 2310, 2375, 2394 + [2, 1] + when 1947, 2004, 2042, 2050, 2080, 2118, 2137, 2194, 2270, 2289, 2300, 2338, 2376 + [1, 22] + when 1948, 1994, 2013, 2024, 2043, 2089, 2119, 2138, 2157, 2176, 2195, 2214, 2320, 2396 + [2, 10] + when 1954, 1973, 2011, 2057, 2068, 2087, 2125, 2163, 2231, 2277, 2288, 2345, 2383 + [2, 3] + when 1956, 2002, 2021, 2059, 2078, 2097, 2135, 2154, 2173, 2184, 2203, 2222, 2241, 2279, 2287, 2298, 2355, 2374, 2393 + [2, 12] + when 1958, 1977, 2034, 2140, 2178, 2235, 2254, 2273, 2311, 2349, 2360, 2398 + [2, 18] + when 1960, 1979, 1998, 2006, 2017, 2036, 2055, 2104, 2169, 2188, 2218, 2226, 2237, 2256, 2275, 2313, 2332, 2370, 2389 + [1, 28] + when 1962, 1981, 2000, 2019, 2065, 2076, 2084, 2095, 2133, 2152, 2171, 2190, 2220, 2239, 2285, 2315, 2334, 2353, 2372, 2391 + [2, 5] + when 1965, 1984, 2030, 2049, 2060, 2079, 2117, 2136, 2174, 2182, 2193, 2204, 2250, 2269, 2280, 2318, 2337, 2356 + [2, 2] + when 1966, 2023, 2061, 2099, 2186, 2262, 2281, 2357, 2395 + [1, 21] + when 1967, 1986, 2005, 2062, 2100, 2168, 2233, 2244, 2263, 2282, 2301, 2339, 2377, 2385, 2388 + [2, 9] + when 1968, 2044, 2090, 2120, 2139, 2158, 2177, 2196, 2215, 2234, 2264, 2302, 2340, 2359, 2378, 2397 + [1, 30] + when 1974, 1993, 2012, 2031, 2069, 2077, 2126, 2145, 2156, 2175, 2213, 2232, 2251, 2297, 2346, 2365, 2384 + [1, 23] + when 1978, 1997, 2008, 2054, 2073, 2092, 2103, 2111, 2122, 2141, 2160, 2217, 2228, 2274, 2293, 2331, 2380 + [2, 7] + when 1980, 1999, 2018, 2064, 2113, 2132, 2151, 2170, 2219, 2238, 2284, 2314, 2333, 2352, 2371, 2390 + [2, 16] + when 1985, 2148, 2167, 2205, 2224, 2243 + [2, 20] + when 2319 + [2, 21] + end + Date.civil(year, month_day[0], month_day[1]) if month_day + deepavali: + arguments: year + source: | + month_day = case year + when 2023 + [11, 12] + when 2024 + [10, 31] + when 2025 + [10, 20] + when 2026 + [10, 8] + end + Date.civil(year, month_day[0], month_day[1]) if month_day + hari_raya_haji: + arguments: year + source: | + month_day = case year + when 2023 + [06, 29] + when 2024 + [06, 17] + when 2025 + [06, 7] + when 2026 + [05, 27] + end + Date.civil(year, month_day[0], month_day[1]) if month_day + hari_raya_puasa: + arguments: year + source: | + month_day = case year + when 2023 + [04, 22] + when 2024 + [04, 10] + when 2025 + [03, 31] + when 2026 + [03, 20] + end + Date.civil(year, month_day[0], month_day[1]) if month_day + vesak_day: + arguments: year + source: | + month_day = case year + when 2023 + [06, 02] + when 2024 + [05, 22] + when 2025 + [05, 12] + when 2026 + [05, 31] + end + Date.civil(year, month_day[0], month_day[1]) if month_day + tests: - given: date: '2014-01-01' @@ -51,18 +201,6 @@ tests: options: ["informal"] expect: name: "New Year's Day" - - given: - date: '2014-02-14' - regions: ["sg"] - options: ["informal"] - expect: - name: "Valentine's Day" - - given: - date: '2014-02-15' - regions: ["sg"] - options: ["informal"] - expect: - name: "Total Defence Day" - given: date: '2014-04-18' regions: ["sg"] @@ -87,3 +225,39 @@ tests: options: ["informal"] expect: name: "Christmas Day" + - given: + date: '2016-02-08' + regions: ["sg"] + options: ["observed"] + expect: + name: "Lunar New Year's Day" + - given: + date: '2016-02-09' + regions: ["sg"] + options: ["observed"] + expect: + name: "The second day of Lunar New Year" + - given: + date: '2077-11-15' + regions: ["sg"] + options: ["observed"] + expect: + name: "Deepavali" + - given: + date: '2025-06-06' + regions: ["sg"] + options: ["observed"] + expect: + name: "Hari Raya Haji" + - given: + date: '2025-03-31' + regions: ["sg"] + options: ["observed"] + expect: + name: "Hari Raya Puasa" + - given: + date: '2025-05-12' + regions: ["sg"] + options: ["observed"] + expect: + name: "Vesak Day" \ No newline at end of file diff --git a/spec/validation/month_validator_spec.rb b/spec/validation/month_validator_spec.rb index 53ff06c4..ece85c09 100644 --- a/spec/validation/month_validator_spec.rb +++ b/spec/validation/month_validator_spec.rb @@ -68,4 +68,56 @@ } end end + + context 'date specification validation' do + it 'allows holiday with mday' do + months = { 1 => [{"name"=>"Test Holiday", "regions"=>["test"], "mday"=>1}] } + expect(subject.call(months)).to be true + end + + it 'allows holiday with function' do + months = { 1 => [{"name"=>"Test Holiday", "regions"=>["test"], "function"=>"custom_method(year)"}] } + expect(subject.call(months)).to be true + end + + it 'allows holiday with wday and week' do + months = { 1 => [{"name"=>"Test Holiday", "regions"=>["test"], "wday"=>1, "week"=>2}] } + expect(subject.call(months)).to be true + end + + it 'returns error if holiday has no date specification' do + months = { 1 => [{"name"=>"Test Holiday", "regions"=>["test"]}] } + expect { subject.call(months) }.to raise_error(Definitions::Errors::MissingDateSpecification) { |e| + expect(e.message).to eq("Holiday 'Test Holiday' must have either 'mday', 'function', or both 'wday' and 'week' attributes to specify the date") + } + end + + it 'returns error if holiday has wday but no week' do + months = { 1 => [{"name"=>"Test Holiday", "regions"=>["test"], "wday"=>1}] } + expect { subject.call(months) }.to raise_error(Definitions::Errors::MissingDateSpecification) { |e| + expect(e.message).to eq("Holiday 'Test Holiday' with 'wday' must also have 'week' attribute (and vice versa)") + } + end + + it 'returns error if holiday has week but no wday' do + months = { 1 => [{"name"=>"Test Holiday", "regions"=>["test"], "week"=>1}] } + expect { subject.call(months) }.to raise_error(Definitions::Errors::MissingDateSpecification) { |e| + expect(e.message).to eq("Holiday 'Test Holiday' with 'wday' must also have 'week' attribute (and vice versa)") + } + end + + it 'returns error if holiday has empty function' do + months = { 1 => [{"name"=>"Test Holiday", "regions"=>["test"], "function"=>""}] } + expect { subject.call(months) }.to raise_error(Definitions::Errors::MissingDateSpecification) { |e| + expect(e.message).to eq("Holiday 'Test Holiday' must have either 'mday', 'function', or both 'wday' and 'week' attributes to specify the date") + } + end + + it 'returns error if holiday has nil function' do + months = { 1 => [{"name"=>"Test Holiday", "regions"=>["test"], "function"=>nil}] } + expect { subject.call(months) }.to raise_error(Definitions::Errors::MissingDateSpecification) { |e| + expect(e.message).to eq("Holiday 'Test Holiday' must have either 'mday', 'function', or both 'wday' and 'week' attributes to specify the date") + } + end + end end diff --git a/th.yaml b/th.yaml new file mode 100644 index 00000000..6143f08c --- /dev/null +++ b/th.yaml @@ -0,0 +1,144 @@ +# Thai holiday definitions for the Ruby Holiday gem. +# +# Updated: 2018-10-17. +# Sources: +# - Photo in this trello card https://trello.com/c/zSDdA4Zy/39-add-public-holidays +--- +months: + 1: + - name: New Year's Day + regions: [th] + mday: 1 + observed: to_monday_if_weekend(date) + 3: + - name: Makha Bucha Day + regions: [th] + mday: 1 + 4: + - name: Chakri Memorial Day + regions: [th] + mday: 6 + - name: Songkran Day + regions: [th] + mday: 13 + - name: Songkran Festival + regions: [th] + mday: 16 + 5: + - name: National Labour Day + regions: [th] + mday: 1 + - name: Wisakha Bucha Day + regions: [th] + mday: 29 + 7: + - name: Asarnha Bucha Day + regions: [th] + mday: 27 + - name: H.M. King Maha Vajiralongkorn Bodindradebayavarangkun's Birthday + regions: [th] + mday: 28 + observed: to_monday_if_weekend(date) + 8: + - name: H.M. Queen Sirikit's Birthday + regions: [th] + mday: 12 + observed: to_monday_if_weekend(date) + 10: + - name: Commemoration of the Passing King Bhumibol + regions: [th] + mday: 13 + observed: to_monday_if_weekend(date) + - name: Chulalongkorn Day + regions: [th] + mday: 23 + 12: + - name: Late King Bhumibol Adulyadej's Birthday, National Day and National Father's Day + regions: [th] + mday: 5 + - name: Constitution Day + regions: [th] + mday: 10 + - name: Year's End Day + regions: [th] + mday: 31 + +tests: + - given: + date: '2016-01-01' + regions: ["th"] + expect: + name: "New Year's Day" + - given: + date: '2016-03-01' + regions: ["th"] + expect: + name: "Makha Bucha Day" + - given: + date: '2016-04-06' + regions: ["th"] + expect: + name: "Chakri Memorial Day" + - given: + date: '2016-04-13' + regions: ["th"] + expect: + name: "Songkran Day" + - given: + date: '2016-04-16' + regions: ["th"] + expect: + name: "Songkran Festival" + - given: + date: '2016-05-01' + regions: ["th"] + expect: + name: "National Labour Day" + - given: + date: '2016-05-29' + regions: ["th"] + expect: + name: "Wisakha Bucha Day" + - given: + date: '2016-07-27' + regions: ["th"] + expect: + name: "Asarnha Bucha Day" + - given: + date: '2016-07-28' + regions: ["th"] + options: ["observed"] + expect: + name: "H.M. King Maha Vajiralongkorn Bodindradebayavarangkun's Birthday" + - given: + date: '2016-08-12' + regions: ["th"] + options: ["observed"] + expect: + name: "H.M. Queen Sirikit's Birthday" + - given: + date: '2016-10-13' + regions: ["th"] + options: ["observed"] + expect: + name: "Commemoration of the Passing King Bhumibol" + - given: + date: '2016-10-23' + regions: ["th"] + expect: + name: "Chulalongkorn Day" + - given: + date: '2016-12-05' + regions: ["th"] + expect: + name: "Late King Bhumibol Adulyadej's Birthday, National Day and National Father's Day" + - given: + date: '2016-12-10' + regions: ["th"] + expect: + name: "Constitution Day" + - given: + date: '2016-12-31' + regions: ["th"] + expect: + name: "Year's End Day" diff --git a/us.yaml b/us.yaml index 49af7d07..a86371c8 100644 --- a/us.yaml +++ b/us.yaml @@ -11,6 +11,9 @@ # - Add helpful comments # - Add a lot of used sources # +# Changed: 2021-10-15 +# - Updated Christmas to Weekday +# # Common Sources: # - http://en.wikipedia.org/wiki/Public_holidays_of_the_United_States # - https://www.timeanddate.com/holidays/us/ @@ -35,7 +38,6 @@ # - https://en.wikipedia.org/wiki/Washington%27s_Birthday # - https://en.wikipedia.org/wiki/Shrove_Tuesday # - https://en.wikipedia.org/wiki/Town_meeting#Vermont -# - https://en.wikipedia.org/wiki/Casimir_Pulaski_Day # - https://en.wikipedia.org/wiki/Seward%27s_Day # - https://en.wikipedia.org/wiki/Emancipation_Day # - https://en.wikipedia.org/wiki/Patriots%27_Day @@ -94,19 +96,19 @@ months: regions: [us] mday: 1 observed: to_weekday_if_weekend(date) - - name: Martin Luther King's and Robert E. Lee's Birthdays # renamed Martin Luther King, Jr. Day + - name: Martin Luther King's and Robert E. Lee's Birthdays # renamed Martin Luther King Jr. Day regions: [us_ms] week: 3 wday: 1 - - name: Idaho Human Rights Day # renamed Martin Luther King, Jr. Day + - name: Idaho Human Rights Day # renamed Martin Luther King Jr. Day regions: [us_id] week: 3 wday: 1 - - name: Civil Rights Day # renamed Martin Luther King, Jr. Day + - name: Civil Rights Day # renamed Martin Luther King Jr. Day regions: [us_ar] week: 3 wday: 1 - - name: Martin Luther King, Jr. Day # Third Monday in January + - name: Martin Luther King Jr. Day # Third Monday in January regions: [us] week: 3 wday: 1 @@ -125,10 +127,6 @@ months: regions: [us] wday: 1 3: - - name: Casimir Pulaski Day # First Monday in March - regions: [us_il] - week: 1 - wday: 1 - name: Town Meeting Day # First Tuesday in March regions: [us_vt] week: 1 @@ -149,7 +147,7 @@ months: mday: 31 4: - name: Emancipation Day - regions: [us_dc, us_ca] + regions: [us_dc] observed: to_weekday_if_weekend(date) mday: 16 - name: Patriots' Day # Third Monday in April @@ -196,6 +194,10 @@ months: regions: [us_hi] observed: to_weekday_if_weekend(date) mday: 11 + - name: Juneteenth National Independence Day + regions: [us] + mday: 19 + observed: to_weekday_if_weekend(date) - name: Emancipation Day in Texas # fixed regions: [us_tx] mday: 19 @@ -263,7 +265,7 @@ months: wday: 5 11: - name: Election Day - regions: [us_de, us_hi, us_il, us_in, us_mt, us_nj, us_ny, us_pa, us_ri] + regions: [us_de, us_hi, us_in, us_mt, us_nj, us_ny, us_pa, us_ri] function: election_day(year) - name: Veterans Day regions: [us] @@ -302,7 +304,7 @@ months: - name: Christmas Day regions: [us] mday: 25 - observed: to_monday_if_weekend(date) + observed: to_weekday_if_weekend(date) - name: Day after Christmas regions: [us_ar, us_nc, us_ok, us_sc, us_tn, us_tx] mday: 26 @@ -350,7 +352,7 @@ methods: state_holiday = Date.civil(year, month, 26) state_holiday.downto(beginning_of_month).find {|date| date if date.wday == 1 } lee_jackson_day: - # Friday before Martin Luther King, Jr. Day + # Friday before Martin Luther King Jr. Day arguments: year, month source: | day_of_holiday = Holidays::Factory::DateCalculator.day_of_month_calculator.call(year, month, 3, 1) @@ -371,7 +373,6 @@ methods: arguments: year source: | Holidays::Factory::DateCalculator.day_of_month_calculator.call(year, 11, 4, 4) + 1 - tests: - given: date: ['2017-2-28', '2018-2-13', '2019-3-5'] @@ -434,13 +435,13 @@ tests: date: ['2017-1-16', '2018-1-15', '2019-1-21'] regions: ["us"] expect: - name: "Martin Luther King, Jr. Day" + name: "Martin Luther King Jr. Day" - given: date: ['2016-1-18', '2017-1-16', '2018-1-15'] regions: ["us"] expect: - name: "Martin Luther King, Jr. Day" + name: "Martin Luther King Jr. Day" - given: date: ['2016-1-18', '2017-1-16', '2018-1-15'] regions: ["us_ms"] @@ -496,11 +497,6 @@ tests: regions: ["us"] expect: holiday: false - - given: - date: ['2017-3-6', '2018-3-5', '2019-3-4'] - regions: ["us_il"] - expect: - name: "Casimir Pulaski Day" - given: date: ['2017-3-7', '2018-3-6', '2019-3-5'] @@ -567,7 +563,7 @@ tests: name: "Emancipation Day" - given: date: ['2017-4-16'] - regions: ["us_dc", "us_ca"] + regions: ["us_dc"] expect: name: "Emancipation Day" @@ -703,6 +699,12 @@ tests: regions: ["us"] expect: holiday: false + - given: + date: ['2021-06-18'] + regions: ["us"] + options: ["observed"] + expect: + name: "Juneteenth National Independence Day" - given: date: ['2017-6-20', '2020-6-19', '2021-6-21'] regions: ["us_wv"] @@ -860,7 +862,7 @@ tests: holiday: false - given: date: ['2017-11-7', '2018-11-6', '2021-11-2'] - regions: ["us_de", "us_hi", "us_il", "us_in", "us_mt", "us_nj", "us_ny", "us_pa", "us_ri"] + regions: ["us_de", "us_hi", "us_in", "us_mt", "us_nj", "us_ny", "us_pa", "us_ri"] expect: name: "Election Day" - given: @@ -928,12 +930,12 @@ tests: name: "Christmas Eve" - given: - date: ['2021-12-27', '2022-12-26', '2027-12-27'] + date: ['2021-12-27', '2022-12-23', '2027-12-27'] regions: ["us"] expect: holiday: false - given: - date: ['2021-12-27', '2022-12-26', '2027-12-27'] + date: ['2021-12-24', '2022-12-26', '2027-12-24'] regions: ["us"] options: ["observed"] expect: diff --git a/uy.yaml b/uy.yaml new file mode 100644 index 00000000..53f5f3e9 --- /dev/null +++ b/uy.yaml @@ -0,0 +1,54 @@ +# Uruguay holiday definitions for the Ruby Holiday gem. +# +# Updated: 2022-09-13. +# +# - Sourced from LATAM Office +--- +months: + 1: + - name: Año Nuevo + regions: [uy] + mday: 1 + 5: + - name: Dia Del Trabajador + regions: [uy] + mday: 1 + 7: + - name: Jura Constitución + regions: [uy] + mday: 18 + 8: + - name: Día Independencia + regions: [uy] + mday: 25 + 12: + - name: Navidad + regions: [uy] + mday: 25 + +tests: + - given: + date: '2012-01-01' + regions: ["uy"] + expect: + name: "Año Nuevo" + - given: + date: '2022-05-01' + regions: ["uy"] + expect: + name: 'Dia Del Trabajador' + - given: + date: '2023-07-18' + regions: ["uy"] + expect: + name: 'Jura Constitución' + - given: + date: '2023-08-25' + regions: ["uy"] + expect: + name: 'Día Independencia' + - given: + date: '2017-12-25' + regions: ["uy"] + expect: + name: 'Navidad' \ No newline at end of file