Skip to content

Commit

Permalink
Add Bermuda public holidays
Browse files Browse the repository at this point in the history
Signed-off-by: XSpielinbox <[email protected]>
  • Loading branch information
XSpielinbox committed Aug 24, 2023
1 parent 37638e4 commit 4e7a633
Show file tree
Hide file tree
Showing 12 changed files with 327 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
public enum HolidayCalendar {

ALBANIA("AL"), ARGENTINA("AR"), AUSTRIA("AT"), AUSTRALIA("AU"),
BOSNIA_HERZIGOWINA("BA"), BELGIUM("BE"), BULGARIA("BG"), BOLIVIA("BO"), BRAZIL("BR"), BELARUS("BY"), BRITISH_VIRGIN_ISLANDS("VG"),
BOSNIA_HERZIGOWINA("BA"), BELGIUM("BE"), BERMUDA("BM"), BULGARIA("BG"), BOLIVIA("BO"), BRAZIL("BR"), BELARUS("BY"), BRITISH_VIRGIN_ISLANDS("VG"),
CANADA(Locale.CANADA.getCountry()), CAYMAN_ISLANDS("KY"), CHILE("CL"), COLOMBIA("CO"), COSTA_RICA("CR"), CROATIA("HR"), CZECH_REPUBLIC("CZ"),
DOW_JONES_STOXX("DJ_STOXX"), DENMARK("DK"),
ECUADOR("EC"), EGYPT("EG"), ESTONIA("EE"), ETHIOPIA("ET"),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
holiday.description.1949_GREAT_MARCH_AND_RESTORATION= The Commemoration of the 1949 Great March and the Restoration of the Legislative Council
holiday.description.170_ANNIVERSARY_ARRIVAL_BERMUDA = 170th Anniversary of the arrival of the first Portuguese immigrants in Bermuda
holiday.description.ADELAIDE_CUP = Adelaide Cup
holiday.description.AE_COMMEMORATION_DAY = Commemoration Day
holiday.description.AFL = AFL Grand Final Friday
Expand All @@ -23,6 +24,7 @@ holiday.description.BATTLE_BOYNE = Battle of the Boyne
holiday.description.BATTLE_JACINTO = Battle of San Jacinto
holiday.description.BEER_DAY = Beer Day
holiday.description.BENNINGTON = Battle of Bennington
holiday.description.BERMUDA_DAY = Bermuda Day
holiday.description.BLACK_AWARENESS = Black Awareness Day
holiday.description.BOLIVAR = Birthday of Simón Bolivar
holiday.description.BOXING_DAY = Boxing Day
Expand Down Expand Up @@ -82,6 +84,7 @@ holiday.description.EGYPT_SINAI_LIBERATION = Sinai Liberation Day
holiday.description.EIGHT = Eight hours day
holiday.description.EKKA = Ekka Wednesday
holiday.description.ELECTION_DAY = Election day
holiday.description.EMANCIPATION_DAY = Emancipation Day
holiday.description.EMANCIPATION_MONDAY = Emancipation Monday
holiday.description.EMANCIPATION_TUESDAY = Emancipation Tuesday
holiday.description.EMANCIPATION_WEDNESDAY = Emancipation Wednesday
Expand Down Expand Up @@ -163,6 +166,7 @@ holiday.description.MARTINS_DAY = Martin of Tours Day
holiday.description.MARTIN_DAY = José de San Martín Day
holiday.description.MARTIN_LUTHER_KING = Martin Luther King, Jr. Day
holiday.description.MARTYRS_DAY = Martyrs Day
holiday.description.MARY_PRINCE_DAY = Mary Prince Day
holiday.description.MATARIKI = Matariki
holiday.description.MAY_DAY = May Day
holiday.description.MAY_REVOLUTION = May Revolution
Expand Down Expand Up @@ -230,6 +234,7 @@ holiday.description.SETTLER = Settlers' Day
holiday.description.SEWARD = Seward's Day
holiday.description.SHOWA_DAY = Showa Day
holiday.description.SOLIDARITY_DAY = Solidarity Day
holiday.description.SOMERS_DAY = Somers Day
holiday.description.SOUTHLAND_ANNIVERSARY = Southland Anniversary
holiday.description.SOVEREIGNS_BIRTHDAY = Sovereign's Birthday
holiday.description.SPRING_BANK_HOLIDAY = Spring Bank Holiday
Expand Down
118 changes: 118 additions & 0 deletions jollyday-core/src/main/resources/holidays/Holidays_bm.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
<?xml version="1.0" encoding="UTF-8"?>
<tns:Configuration hierarchy="bm" description="Bermuda" xmlns:tns="http://www.example.org/Holiday"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.example.org/Holiday /Holiday.xsd">
<tns:Holidays>
<tns:Fixed month="JANUARY" day="1" descriptionPropertiesKey="NEW_YEAR">
<tns:MovingCondition substitute="SUNDAY" with="NEXT" weekday="MONDAY"/>
<tns:MovingCondition substitute="SATURDAY" with="NEXT" weekday="MONDAY"/>
</tns:Fixed>

<!-- https://www.gov.bm/theofficialgazette/notices/gn03142023 -->
<!-- https://www.gov.bm/public-holidays -->
<tns:Fixed month="MAY" day="8" validFrom="2023" validTo="2023" descriptionPropertiesKey="KINGS_CORONATION"/>

<tns:Fixed month="MAY" day="24" validFrom="1979" validTo="2017" descriptionPropertiesKey="BERMUDA_DAY">
<tns:MovingCondition substitute="SATURDAY" with="NEXT" weekday="MONDAY"/>
<tns:MovingCondition substitute="SUNDAY" with="NEXT" weekday="MONDAY"/>
</tns:Fixed>

<!-- 2019 it was moved one week earlier -->
<tns:Fixed month="MAY" day="24" validFrom="2019" validTo="2019" descriptionPropertiesKey="BERMUDA_DAY"/>

<!-- the Thursday before the first Monday in August -->

<!-- the start year may be wrong, it is currently set to the earliest possible year -->
<!-- fourth / last Thursday in July -->
<tns:Fixed month="JULY" day="28" validFrom="1947" validTo="2016" descriptionPropertiesKey="EMANCIPATION_DAY"/>
<!-- first Thursday in August -->
<tns:Fixed month="AUGUST" day="3" validFrom="2017" validTo="2017" descriptionPropertiesKey="EMANCIPATION_DAY"/>
<!-- first Thursday in August -->
<tns:Fixed month="AUGUST" day="2" validFrom="2018" validTo="2018" descriptionPropertiesKey="EMANCIPATION_DAY"/>
<!-- first Thursday in August -->
<tns:Fixed month="AUGUST" day="1" validFrom="2019" validTo="2019" descriptionPropertiesKey="EMANCIPATION_DAY"/>
<!-- fifth / last Thursday in July -->
<tns:Fixed month="JULY" day="30" validFrom="2020" validTo="2020" descriptionPropertiesKey="EMANCIPATION_DAY"/>
<!-- https://www.gov.bm/theofficialgazette/notices/gn00492021 -->
<!-- fifth / last Thursday in July -->
<tns:Fixed month="JULY" day="29" validFrom="2021" validTo="2021" descriptionPropertiesKey="EMANCIPATION_DAY"/>
<!-- https://www.gov.bm/theofficialgazette/notices/gn00502021 -->
<!-- fourth / last Thursday in July -->
<tns:Fixed month="JULY" day="28" validFrom="2022" validTo="2022" descriptionPropertiesKey="EMANCIPATION_DAY"/>
<!-- https://www.gov.bm/theofficialgazette/notices/gn00502021 -->
<!-- first Thursday in August -->
<tns:Fixed month="AUGUST" day="3" validFrom="2023" validTo="2023" descriptionPropertiesKey="EMANCIPATION_DAY"/>
<!-- https://www.gov.bm/theofficialgazette/notices/gn03652022 -->
<!-- first Thursday in August -->
<tns:Fixed month="AUGUST" day="1" validFrom="2024" validTo="2024" descriptionPropertiesKey="EMANCIPATION_DAY"/>
<!-- https://www.gov.bm/theofficialgazette/notices/gn03662022 -->
<!-- fifth / last Thursday in July -->
<tns:Fixed month="JULY" day="31" validFrom="2025" descriptionPropertiesKey="EMANCIPATION_DAY"/>

<!-- the Friday before the first Monday in August -->

<!-- the start year may be wrong, it is currently set to the earliest possible year -->
<!-- fourth / last Friday in July -->
<tns:Fixed month="JULY" day="29" validFrom="1947" validTo="2016" descriptionPropertiesKey="SOMERS_DAY"/>
<!-- first Friday in August -->
<tns:Fixed month="AUGUST" day="4" validFrom="2017" validTo="2017" descriptionPropertiesKey="SOMERS_DAY"/>
<!-- first Friday in August -->
<tns:Fixed month="AUGUST" day="3" validFrom="2018" validTo="2018" descriptionPropertiesKey="SOMERS_DAY"/>
<!-- first Friday in August -->
<tns:Fixed month="AUGUST" day="2" validFrom="2019" validTo="2019" descriptionPropertiesKey="SOMERS_DAY"/>

<!-- the Friday before the first Monday in August -->

<!-- fifth / last Friday in July -->
<tns:Fixed month="JULY" day="31" validFrom="2020" validTo="2020" descriptionPropertiesKey="MARY_PRINCE_DAY"/>
<!-- https://www.gov.bm/theofficialgazette/notices/gn00492021 -->
<!-- fifth / last Friday in July -->
<tns:Fixed month="JULY" day="30" validFrom="2021" validTo="2021" descriptionPropertiesKey="MARY_PRINCE_DAY"/>
<!-- https://www.gov.bm/theofficialgazette/notices/gn00502021 -->
<!-- fifth / last Friday in July -->
<tns:Fixed month="JULY" day="29" validFrom="2022" validTo="2022" descriptionPropertiesKey="MARY_PRINCE_DAY"/>
<!-- https://www.gov.bm/theofficialgazette/notices/gn00502021 -->
<!-- first Friday in August -->
<tns:Fixed month="AUGUST" day="4" validFrom="2023" validTo="2023" descriptionPropertiesKey="MARY_PRINCE_DAY"/>
<!-- https://www.gov.bm/theofficialgazette/notices/gn03652022 -->
<!-- first Friday in August -->
<tns:Fixed month="AUGUST" day="2" validFrom="2024" validTo="2024" descriptionPropertiesKey="MARY_PRINCE_DAY"/>
<!-- https://www.gov.bm/theofficialgazette/notices/gn03662022 -->
<!-- first Friday in August -->
<tns:Fixed month="AUGUST" day="1" validFrom="2025" descriptionPropertiesKey="MARY_PRINCE_DAY"/>

<!-- https://culture.bm/photo/national-heroes-day/ -->
<tns:Fixed month="OCTOBER" day="12" validFrom="2008" validTo="2008" descriptionPropertiesKey="NATIONAL_HEROES_DAY"/>

<tns:Fixed month="NOVEMBER" day="4" validFrom="2019" validTo="2019" descriptionPropertiesKey="170_ANNIVERSARY_ARRIVAL_BERMUDA"/>

<!-- the start year may be wrong, it is currently set to the earliest possible year -->
<tns:Fixed month="NOVEMBER" day="11" validFrom="1919" descriptionPropertiesKey="REMEMBRANCE">
<tns:MovingCondition substitute="SATURDAY" with="NEXT" weekday="MONDAY"/>
<tns:MovingCondition substitute="SUNDAY" with="NEXT" weekday="MONDAY"/>
</tns:Fixed>

<tns:Fixed month="DECEMBER" day="25" descriptionPropertiesKey="CHRISTMAS">
<tns:MovingCondition substitute="SATURDAY" with="NEXT" weekday="MONDAY"/>
<tns:MovingCondition substitute="SUNDAY" with="NEXT" weekday="MONDAY"/>
</tns:Fixed>
<tns:Fixed month="DECEMBER" day="26" descriptionPropertiesKey="BOXING_DAY">
<tns:MovingCondition substitute="SUNDAY" with="NEXT" weekday="TUESDAY"/>
<tns:MovingCondition substitute="MONDAY" with="NEXT" weekday="TUESDAY"/>
<tns:MovingCondition substitute="SATURDAY" with="NEXT" weekday="MONDAY"/>
</tns:Fixed>

<tns:FixedWeekday which="LAST" weekday="FRIDAY" month="MAY" validFrom="2018" validTo="2018" descriptionPropertiesKey="BERMUDA_DAY"/>
<!-- 2019 it was moved one week earlier - see above -->
<tns:FixedWeekday which="LAST" weekday="FRIDAY" month="MAY" validFrom="2020" validTo="2020" descriptionPropertiesKey="BERMUDA_DAY"/>

<!-- the Friday before the last Monday in May -->
<tns:FixedWeekday which="FOURTH" weekday="FRIDAY" month="MAY" validFrom="2021" descriptionPropertiesKey="BERMUDA_DAY"/>

<tns:FixedWeekday which="THIRD" weekday="MONDAY" month="JUNE" validFrom="2009" descriptionPropertiesKey="NATIONAL_HEROES_DAY"/>

<tns:FixedWeekday which="FIRST" weekday="MONDAY" month="SEPTEMBER" descriptionPropertiesKey="LABOUR_DAY"/>

<tns:ChristianHoliday type="GOOD_FRIDAY" descriptionPropertiesKey="christian.GOOD_FRIDAY"/>
</tns:Holidays>
</tns:Configuration>
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package de.focus_shift.tests;

import de.focus_shift.Holiday;
import de.focus_shift.HolidayCalendar;
import de.focus_shift.HolidayManager;
import de.focus_shift.ManagerParameters;
import de.focus_shift.tests.base.AbstractCountryTestBase;
import de.focus_shift.util.CalendarUtil;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;

import java.time.LocalDate;
import java.util.List;
import java.util.Locale;
import java.util.Set;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.fail;

public class HolidayBMTest extends AbstractCountryTestBase {

private static final String ISO_CODE = "bm";

private final CalendarUtil calendarUtil = new CalendarUtil();

@ParameterizedTest
@ValueSource(ints = {2017, 2018, 2020, 2021, 2022, 2023, 2024, 2025})
void testManagerVGStructure(final int year) {
validateCalendarData(ISO_CODE, year, true);
}

@Test
void testManagerVGInterval() {
try {
final HolidayManager instance = HolidayManager.getInstance(ManagerParameters.create(HolidayCalendar.BERMUDA, null));
final LocalDate startDateInclusive = calendarUtil.create(2022, 10, 1);
final LocalDate endDateInclusive = calendarUtil.create(2023, 1, 31);
final Set<Holiday> holidays = instance.getHolidays(startDateInclusive, endDateInclusive);
final List<LocalDate> expected = List.of(calendarUtil.create(2022, 11, 11),
calendarUtil.create(2022, 12, 26), calendarUtil.create(2022, 12, 27),
calendarUtil.create(2023, 1, 2));
assertThat(holidays).hasSameSizeAs(expected);
for (LocalDate d : expected) {
assertThat(calendarUtil.contains(holidays, d)).isTrue();
}
} catch (Exception e) {
fail("Unexpected error occurred: " + e.getClass().getName() + " - " + e.getMessage());
}
}

@Test
void testManagerDifferentInstance() {
final Locale defaultLocale = Locale.getDefault();
Locale.setDefault(Locale.US);
try {
final HolidayManager defaultManager = HolidayManager.getInstance();
final HolidayManager virginIslandsManager = HolidayManager.getInstance(ManagerParameters.create(HolidayCalendar.BERMUDA, null));
assertThat(defaultManager).isNotEqualTo(virginIslandsManager);
} catch (Exception e) {
fail("Unexpected error occurred: " + e.getClass().getName() + " - " + e.getMessage());
} finally {
Locale.setDefault(defaultLocale);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<tns:Configuration hierarchy="bm" description="Bermuda" xmlns:tns="http://www.example.org/Holiday"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.example.org/Holiday /Holiday.xsd">
<tns:Holidays>
<tns:Fixed month="JANUARY" day="2" descriptionPropertiesKey="NEW_YEAR"/>
<tns:Fixed month="APRIL" day="14" descriptionPropertiesKey="christian.GOOD_FRIDAY"/>
<tns:Fixed month="MAY" day="24" descriptionPropertiesKey="BERMUDA_DAY"/>
<tns:Fixed month="JUNE" day="19" descriptionPropertiesKey="NATIONAL_HEROES_DAY"/>
<tns:Fixed month="AUGUST" day="3" descriptionPropertiesKey="EMANCIPATION_DAY"/>
<tns:Fixed month="AUGUST" day="4" descriptionPropertiesKey="SOMERS_DAY"/>
<tns:Fixed month="SEPTEMBER" day="4" descriptionPropertiesKey="LABOUR_DAY"/>
<tns:Fixed month="NOVEMBER" day="13" descriptionPropertiesKey="REMEMBRANCE"/>
<tns:Fixed month="DECEMBER" day="25" descriptionPropertiesKey="CHRISTMAS"/>
<tns:Fixed month="DECEMBER" day="26" descriptionPropertiesKey="BOXING_DAY"/>
</tns:Holidays>
</tns:Configuration>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<tns:Configuration hierarchy="bm" description="Bermuda" xmlns:tns="http://www.example.org/Holiday"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.example.org/Holiday /Holiday.xsd">
<tns:Holidays>
<tns:Fixed month="JANUARY" day="1" descriptionPropertiesKey="NEW_YEAR"/>
<tns:Fixed month="MARCH" day="30" descriptionPropertiesKey="christian.GOOD_FRIDAY"/>
<tns:Fixed month="MAY" day="25" descriptionPropertiesKey="BERMUDA_DAY"/>
<tns:Fixed month="JUNE" day="18" descriptionPropertiesKey="NATIONAL_HEROES_DAY"/>
<tns:Fixed month="AUGUST" day="2" descriptionPropertiesKey="EMANCIPATION_DAY"/>
<tns:Fixed month="AUGUST" day="3" descriptionPropertiesKey="SOMERS_DAY"/>
<tns:Fixed month="SEPTEMBER" day="3" descriptionPropertiesKey="LABOUR_DAY"/>
<tns:Fixed month="NOVEMBER" day="12" descriptionPropertiesKey="REMEMBRANCE"/>
<tns:Fixed month="DECEMBER" day="25" descriptionPropertiesKey="CHRISTMAS"/>
<tns:Fixed month="DECEMBER" day="26" descriptionPropertiesKey="BOXING_DAY"/>
</tns:Holidays>
</tns:Configuration>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<tns:Configuration hierarchy="bm" description="Bermuda" xmlns:tns="http://www.example.org/Holiday"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.example.org/Holiday /Holiday.xsd">
<tns:Holidays>
<tns:Fixed month="JANUARY" day="1" descriptionPropertiesKey="NEW_YEAR"/>
<tns:Fixed month="APRIL" day="10" descriptionPropertiesKey="christian.GOOD_FRIDAY"/>
<tns:Fixed month="MAY" day="29" descriptionPropertiesKey="BERMUDA_DAY"/>
<tns:Fixed month="JUNE" day="15" descriptionPropertiesKey="NATIONAL_HEROES_DAY"/>
<tns:Fixed month="JULY" day="30" descriptionPropertiesKey="EMANCIPATION_DAY"/>
<tns:Fixed month="JULY" day="31" descriptionPropertiesKey="MARY_PRINCE_DAY"/>
<tns:Fixed month="SEPTEMBER" day="7" descriptionPropertiesKey="LABOUR_DAY"/>
<tns:Fixed month="NOVEMBER" day="11" descriptionPropertiesKey="REMEMBRANCE"/>
<tns:Fixed month="DECEMBER" day="25" descriptionPropertiesKey="CHRISTMAS"/>
<tns:Fixed month="DECEMBER" day="28" descriptionPropertiesKey="BOXING_DAY"/>
</tns:Holidays>
</tns:Configuration>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<tns:Configuration hierarchy="bm" description="Bermuda" xmlns:tns="http://www.example.org/Holiday"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.example.org/Holiday /Holiday.xsd">
<tns:Holidays>
<tns:Fixed month="JANUARY" day="1" descriptionPropertiesKey="NEW_YEAR"/>
<tns:Fixed month="APRIL" day="2" descriptionPropertiesKey="christian.GOOD_FRIDAY"/>
<tns:Fixed month="MAY" day="28" descriptionPropertiesKey="BERMUDA_DAY"/>
<tns:Fixed month="JUNE" day="21" descriptionPropertiesKey="NATIONAL_HEROES_DAY"/>
<tns:Fixed month="JULY" day="29" descriptionPropertiesKey="EMANCIPATION_DAY"/>
<tns:Fixed month="JULY" day="30" descriptionPropertiesKey="MARY_PRINCE_DAY"/>
<tns:Fixed month="SEPTEMBER" day="6" descriptionPropertiesKey="LABOUR_DAY"/>
<tns:Fixed month="NOVEMBER" day="11" descriptionPropertiesKey="REMEMBRANCE"/>
<tns:Fixed month="DECEMBER" day="27" descriptionPropertiesKey="CHRISTMAS"/>
<tns:Fixed month="DECEMBER" day="28" descriptionPropertiesKey="BOXING_DAY"/>
</tns:Holidays>
</tns:Configuration>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<tns:Configuration hierarchy="bm" description="Bermuda" xmlns:tns="http://www.example.org/Holiday"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.example.org/Holiday /Holiday.xsd">
<tns:Holidays>
<tns:Fixed month="JANUARY" day="3" descriptionPropertiesKey="NEW_YEAR"/>
<tns:Fixed month="APRIL" day="15" descriptionPropertiesKey="christian.GOOD_FRIDAY"/>
<tns:Fixed month="MAY" day="27" descriptionPropertiesKey="BERMUDA_DAY"/>
<tns:Fixed month="JUNE" day="20" descriptionPropertiesKey="NATIONAL_HEROES_DAY"/>
<tns:Fixed month="JULY" day="28" descriptionPropertiesKey="EMANCIPATION_DAY"/>
<tns:Fixed month="JULY" day="29" descriptionPropertiesKey="MARY_PRINCE_DAY"/>
<tns:Fixed month="SEPTEMBER" day="5" descriptionPropertiesKey="LABOUR_DAY"/>
<tns:Fixed month="NOVEMBER" day="11" descriptionPropertiesKey="REMEMBRANCE"/>
<tns:Fixed month="DECEMBER" day="26" descriptionPropertiesKey="CHRISTMAS"/>
<tns:Fixed month="DECEMBER" day="27" descriptionPropertiesKey="BOXING_DAY"/>
</tns:Holidays>
</tns:Configuration>
Loading

0 comments on commit 4e7a633

Please sign in to comment.