Skip to content

Commit

Permalink
Merge pull request #279 from XSpielinbox/pr5
Browse files Browse the repository at this point in the history
Add Mauritius public holidays
  • Loading branch information
derTobsch authored Sep 22, 2023
2 parents 18eac00 + c1a3603 commit 02f38fe
Show file tree
Hide file tree
Showing 28 changed files with 1,099 additions and 323 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ target/
.project

# jqwik
/jollyday-tests/.jqwik-database
.jqwik-database
5 changes: 5 additions & 0 deletions jollyday-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@
<artifactId>xmlunit-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.jqwik</groupId>
<artifactId>jqwik</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public enum HolidayCalendar {
JAPAN("JP"),
KAZAKHSTAN("KZ"), KOSOVO("XK"),
LATVIA("LV"), LIECHTENSTEIN("LI"), LITHUANIA("LT"), LONDON_METAL_EXCHANGE("LME"), LUXEMBOURG("LU"),
MACEDONIA("MK"), MALTA("MT"), MEXICO("MX"), MOLDOVA("MD"), MONTENEGRO("ME"),
MACEDONIA("MK"), MALTA("MT"), MAURITIUS("MU"), MEXICO("MX"), MOLDOVA("MD"), MONTENEGRO("ME"),
NETHERLANDS("NL"), NEW_ZEALAND("NZ"), NICARAGUA("NI"), NIGERIA("NG"), NORWAY("NO"), NYSE("NYSE"),
PANAMA("PA"), PARAGUAY("PY"), PERU("PE"), POLAND("PL"), PORTUGAL("PT"),
ROMANIA("RO"), RUSSIA("RU"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,31 +21,37 @@ public boolean test(Limited limited) {
return year % 2 != 0;
case EVEN_YEARS:
return year % 2 == 0;
case TWO_YEARS:
return isValidWithReferenceYear(limited, 2);
case THREE_YEARS:
return isValidWithReferenceYear(limited, 3);
case FOUR_YEARS:
return isValidWithReferenceYear(limited, 4);
case FIVE_YEARS:
return isValidWithReferenceYear(limited, 5);
case SIX_YEARS:
return isValidWithReferenceYear(limited, 6);
default:
if (limited.validFrom() != null) {
int cycleYears;
switch (limited.cycle()) {
case TWO_YEARS:
cycleYears = 2;
break;
case THREE_YEARS:
cycleYears = 3;
break;
case FOUR_YEARS:
cycleYears = 4;
break;
case FIVE_YEARS:
cycleYears = 5;
break;
case SIX_YEARS:
cycleYears = 6;
break;
default:
throw new IllegalArgumentException("Cannot handle unknown cycle type '" + limited.cycle() + "'.");
}
return (year - limited.validFrom().getValue()) % cycleYears == 0;
}
throw new IllegalArgumentException("Cannot handle unknown cycle type '" + limited.cycle() + "'.");
}
return true;
}

/**
* Will validate if a given year based on the reference year (validFrom/validTo) is valid bases on the cycle strategy.
* <p>
* Note: no need to test whether we are in range, as this is already done in {@link ValidFromTo}
*
* @param limited provides the reference years. First we use validFrom and if not given validTo
* @param cycleYears number of years to start the cycle starting from validFrom/validTo
* @return true if the given year based on validFrom/validTo and the cycle is valid, otherwise false
*/
private boolean isValidWithReferenceYear(Limited limited, int cycleYears) {
if (limited.validFrom() != null) {
return (year - limited.validFrom().getValue()) % cycleYears == 0;
} else if (limited.validTo() != null) {
return (limited.validTo().getValue() - year) % cycleYears == 0;
}

throw new IllegalArgumentException("Cannot handle cycle type '" + limited.cycle() + "' without any reference year.");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,10 @@ country.description.ch.bs = Basel-City
country.description.ch.fr = Fribourg
country.description.ch.ge = Geneva
country.description.ch.gl = Glarus
country.description.ch.gr = Graub�nden
country.description.ch.gr = Graubünden
country.description.ch.ju = Jura
country.description.ch.lu = Lucerne
country.description.ch.ne = Neuch�tel
country.description.ch.ne = Neuchâtel
country.description.ch.nw = Nidwalden
country.description.ch.ow = Obwalden
country.description.ch.sg = St.Gallen
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
holiday.description.170_ANNIVERSARY_ARRIVAL_BERMUDA = 170th Anniversary of the arrival of the first Portuguese immigrants in Bermuda
holiday.description.1949_GREAT_MARCH_AND_RESTORATION = The Commemoration of the 1949 Great March and the Restoration of the Legislative Council
holiday.description.ABOLITION_OF_SLAVERY = Abolition of Slavery
holiday.description.ADELAIDE_CUP = Adelaide Cup
holiday.description.AE_COMMEMORATION_DAY = Commemoration Day
holiday.description.AFL = AFL Grand Final Friday
Expand All @@ -15,7 +16,9 @@ holiday.description.APARECIDA = Our Lady of Aparecida
holiday.description.ARBOR = Arbor Day
holiday.description.ARMISTICE = Armistice Day
holiday.description.ARMY_DAY = Army Day
holiday.description.ARRIVAL_OF_INDENTURED_LABORERS = Arrival of Indentured Labourers
holiday.description.ARTIGAS = Artigas' Birthday
holiday.description.ASSUMPTION_BLESSED_VIRGIN_MARY = Assumption of the Blessed Virgin Mary
holiday.description.ASSUMPTION_DAY = Assumption day
holiday.description.ASSUMPTION_MARY = Assumption of Mary
holiday.description.AUCKLAND_ANNIVERSARY = Auckland Anniversary
Expand Down Expand Up @@ -44,6 +47,7 @@ holiday.description.CESAR_CHAVEZ = César Chávez's Birthday
holiday.description.CHACO_ARMISTICE = Chaco Armistice
holiday.description.CHATHAM_ISLANDS_ANNIVERSARY = Chatham Islands Anniversary
holiday.description.CHILDRENS_DAY = Children's Day
holiday.description.CHINESE_SPRING_FESTIVAL = Chinese Spring Festival
holiday.description.CHRISTMAS = Christmas
holiday.description.CHRISTMAS_EVE = Christmas Eve
holiday.description.CITY_DAY = Capital day
Expand Down Expand Up @@ -73,6 +77,7 @@ holiday.description.DECLARATION_OF_INDEPENDENCE_DAY = Declaration of Independen
holiday.description.DEFENDER_FATHERLAND = Defender of the Fatherland
holiday.description.DEFENDER_OF_UKRAINE = Defender of Ukraine Day
holiday.description.DISCOVERY_DAY = Discovery Day
holiday.description.DIVALI = Divali
holiday.description.EARLY_MAY_BANK_HOLIDAY = Early May Bank Holiday
holiday.description.EDU_CULTURE = Education, Culture and Literature Day
holiday.description.EGYPT_23_JULY_REVOLUTION = July 23rd Revolution Day
Expand Down Expand Up @@ -111,6 +116,7 @@ holiday.description.FREEDOM = Freedom Day
holiday.description.FREEDOM_DEMOCRACY = Freedom and Democracy Day
holiday.description.FUNERAL_OF_PRESIDENT_REAGAN = Funeral of President Reagan
holiday.description.GALICIAN_LITERATURE = Galician Literature Day
holiday.description.GANESH_CHATURTHI = Ganesh Chaturthi
holiday.description.GENEVAN_FAST = Genevan Fast
holiday.description.GHANDIS_BIRTHDAY = Ghandis birthday
holiday.description.GOODWILL = Day of Goodwill
Expand All @@ -130,6 +136,7 @@ holiday.description.HUS = Jan Hus Day
holiday.description.HUSBANDS_DAY = Husbands Day
holiday.description.IMMACULATE_CONCEPTION = Immaculate Conception Day
holiday.description.IMPERIAL_DAY = Event of imperial mourning or celebration
holiday.description.INDEPENDENCE_AND_REPUBLIC_DAY = Independence and Republic Day
holiday.description.INDEPENDENCE_DAY = Independence Day
holiday.description.INDEP_CUENCA = Independence of Cuenca
holiday.description.INDEP_GUYAQUIL = Independence of Guayaquil
Expand Down Expand Up @@ -162,6 +169,7 @@ holiday.description.LEE_JACKSON = Lee-Jackson Day
holiday.description.LEOPOLD = Leopold III. day
holiday.description.LIBERATION = Liberation Day
holiday.description.LINCOLN = Lincoln's Birthday
holiday.description.MAHA_SHIVRATREE = Maha Shivaratree
holiday.description.MAJORITY_RULE_DAY = Majority Rule Day
holiday.description.MALVINAS = Malvinas Day
holiday.description.MARLBOROUGH_ANNIVERSARY = Marlborough Anniversary
Expand Down Expand Up @@ -203,6 +211,7 @@ holiday.description.PLEBISCITE = Day of the plebiscite
holiday.description.PRESEREN = Prešeren Day
holiday.description.PRESIDENTS_DAY = Presidents Day
holiday.description.PROCLAMATION = Proclamation Day
holiday.description.PUBLIC_HOLIDAY = Public holiday
holiday.description.PULASKI = Casimir Pulaski Day
holiday.description.QUEENS_BIRTHDAY = Queen's birthday
holiday.description.QUEENS_PLATINUM_JUBILEE = Queen's Platinum Jubilee
Expand Down Expand Up @@ -265,6 +274,7 @@ holiday.description.ST_VITUS = St.Vitus' Day
holiday.description.SUMMER_BANK_HOLIDAY = Summer Bank Holiday
holiday.description.TARANAKI_ANNIVERSARY = Taranaki Anniversary
holiday.description.TERRITORY_DAY = Territory Day
holiday.description.THAIPOOSAM_CAVEDEE = Thaipoosam Cavadee
holiday.description.THANKSGIVING = Thanksgiving Day
holiday.description.THEOPHANY = Theophany
holiday.description.THREE_HIERARCHS = The Three Holy Hierarchs
Expand All @@ -277,6 +287,7 @@ holiday.description.TURKEY_DEMOCRATIC_UNITY_DAY = Democracy and National Un
holiday.description.TURKEY_REPUBLIC_DAY = Republic Day
holiday.description.TURKEY_VICTORY_DAY = Victory Day
holiday.description.TYNWALD = Tynwald Day
holiday.description.UGAADI = Ugaadi
holiday.description.UNIFICATION = Unification Day
holiday.description.UNIFICATION_GERMANY = German Unity Day
holiday.description.VETERANS_DAY = Veterans Day
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
holiday.description.170_ANNIVERSARY_ARRIVAL_BERMUDA = 170. Jahrestag der Ankunft der ersten portugiesischen Einwanderer auf den Bermudas
holiday.description.1949_GREAT_MARCH_AND_RESTORATION = Das Gedenken an den Großen Marsch von 1949 und die Wiedereinsetzung des Legislativrats
holiday.description.ABOLITION_OF_SLAVERY = Aufhebung der Sklaverei
holiday.description.ADELAIDE_CUP = Adelaide Cup
holiday.description.AE_COMMEMORATION_DAY = Commemoration Day
holiday.description.AFL = AFL Grand Final Friday
Expand All @@ -15,7 +16,9 @@ holiday.description.APARECIDA = Erscheinung der Gottesmut
holiday.description.ARBOR = Arbor Tag
holiday.description.ARMISTICE = Waffenstillstand
holiday.description.ARMY_DAY = Tag des Heeres
holiday.description.ARRIVAL_OF_INDENTURED_LABORERS = Ankunft der Gastarbeiter
holiday.description.ARTIGAS = Artigas' Geburtstag
holiday.description.ASSUMPTION_BLESSED_VIRGIN_MARY = Mariä Himmelfahrt
holiday.description.ASSUMPTION_DAY = Mariä Himmelfahrt
holiday.description.ASSUMPTION_MARY = Mariä Himmelfahrt
holiday.description.AUCKLAND_ANNIVERSARY = Auckland Anniversary
Expand Down Expand Up @@ -44,6 +47,7 @@ holiday.description.CESAR_CHAVEZ = César Chávez's Geburtst
holiday.description.CHACO_ARMISTICE = Chaco Waffenstillstand
holiday.description.CHATHAM_ISLANDS_ANNIVERSARY = Chatham Islands Anniversary
holiday.description.CHILDRENS_DAY = Kindertag
holiday.description.CHINESE_SPRING_FESTIVAL = Chinesisches Frühlingsfest
holiday.description.CHRISTMAS = Weihnachten
holiday.description.CHRISTMAS_EVE = Heiligabend
holiday.description.CITY_DAY = Hauptstadttag
Expand Down Expand Up @@ -73,6 +77,7 @@ holiday.description.DECLARATION_OF_INDEPENDENCE_DAY = Tag der Erklärung der Un
holiday.description.DEFENDER_FATHERLAND = Verteidiger des Vaterlandes
holiday.description.DEFENDER_OF_UKRAINE = Tag des Verteidigers der Ukraine
holiday.description.DISCOVERY_DAY = Entdeckungstag
holiday.description.DIVALI = Divali
holiday.description.EARLY_MAY_BANK_HOLIDAY = Early May Bank Holiday
holiday.description.EDU_CULTURE = Bildungs-, Kultur- und Literatur-Tag
holiday.description.EGYPT_23_JULY_REVOLUTION = July 23rd Revolution Day
Expand Down Expand Up @@ -111,6 +116,7 @@ holiday.description.FREEDOM = Tag der Freiheit
holiday.description.FREEDOM_DEMOCRACY = Freiheit und Demokratie Tag
holiday.description.FUNERAL_OF_PRESIDENT_REAGAN = Beerdigung von Präsident Reagan
holiday.description.GALICIAN_LITERATURE = Galizischer Literatur Tag
holiday.description.GANESH_CHATURTHI = Ganesh Chaturthi
holiday.description.GENEVAN_FAST = Genevan Fast
holiday.description.GHANDIS_BIRTHDAY = Ghandis Geburtstag
holiday.description.GOODWILL = Tag des Wohlwollens
Expand All @@ -130,6 +136,7 @@ holiday.description.HUS = Jan Hus Tag
holiday.description.HUSBANDS_DAY = Ehemanntag
holiday.description.IMMACULATE_CONCEPTION = Maria Empfängnis
holiday.description.IMPERIAL_DAY = Ereignis kaiserlicher Feierlichkeiten
holiday.description.INDEPENDENCE_AND_REPUBLIC_DAY = Tag der Unabhüngigkeit und der Republik
holiday.description.INDEPENDENCE_DAY = Unabhängigkeitstag
holiday.description.INDEP_CUENCA = Unabhängigkeit von Cuenca
holiday.description.INDEP_GUYAQUIL = Unabhängigkeit von Guayaquil
Expand Down Expand Up @@ -162,6 +169,7 @@ holiday.description.LEE_JACKSON = Lee-Jackson Tag
holiday.description.LEOPOLD = Leopold III. Tag
holiday.description.LIBERATION = Tag der Befreiung
holiday.description.LINCOLN = Lincolns Geburtstag
holiday.description.MAHA_SHIVRATREE = Maha Shivaratree
holiday.description.MAJORITY_RULE_DAY = Tag der Mehrheitsregelungen
holiday.description.MALVINAS = Malvinas Tag
holiday.description.MARLBOROUGH_ANNIVERSARY = Marlborough Anniversary
Expand Down Expand Up @@ -203,6 +211,7 @@ holiday.description.PLEBISCITE = Tag der Volksabstimmung
holiday.description.PRESEREN = Prešeren Tag
holiday.description.PRESIDENTS_DAY = Presidents Day
holiday.description.PROCLAMATION = Proklamationstag
holiday.description.PUBLIC_HOLIDAY = Nationaler Feiertag
holiday.description.PULASKI = Casimir Pulaski Tag
holiday.description.QUEENS_BIRTHDAY = Geburtstag der Königin
holiday.description.QUEENS_PLATINUM_JUBILEE = Queen's Platinum Jubilee
Expand Down Expand Up @@ -265,6 +274,7 @@ holiday.description.ST_VITUS = St.Vitus' Tag
holiday.description.SUMMER_BANK_HOLIDAY = Summer Bank Holiday
holiday.description.TARANAKI_ANNIVERSARY = Taranaki Anniversary
holiday.description.TERRITORY_DAY = Territorialer Tag
holiday.description.THAIPOOSAM_CAVEDEE = Thaipoosam Cavadee
holiday.description.THANKSGIVING = Erntedankfest
holiday.description.THEOPHANY = Theophany
holiday.description.THREE_HIERARCHS = Die 3 Heiligen
Expand All @@ -277,6 +287,7 @@ holiday.description.TURKEY_DEMOCRATIC_UNITY_DAY = Democracy and National Un
holiday.description.TURKEY_REPUBLIC_DAY = Tag der Republik
holiday.description.TURKEY_VICTORY_DAY = Tag des Sieges
holiday.description.TYNWALD = Tynwald Tag
holiday.description.UGAADI = Ugaadi
holiday.description.UNIFICATION = Tag der Wiedervereinigung
holiday.description.UNIFICATION_GERMANY = Tag der Deutschen Einheit
holiday.description.VETERANS_DAY = Veteranen Tag
Expand Down
Loading

0 comments on commit 02f38fe

Please sign in to comment.