Skip to content

Commit

Permalink
Fix the Holidays in French speaking Switzerland (#217)
Browse files Browse the repository at this point in the history
* correct Geneva holidays
using Art. 32 from https://silgeneve.ch/legis/index.aspx as reference

* add missing Vaud (Switzerland) holiday

* add missing Neuchatel (Switzerland) holidays
reference: https://www.ne.ch/themes/travail/Pages/jours-feries.aspx

* add french translations to missing holidays

* correct the Holidays for Fribourg (Switzerland) and add a special locale for the reformed part of Fribourg because it has different holidays
source: https://www.fr.ch/travail-et-entreprises/employes/jours-feries

* Add missing Italian translations for swiss holidays

* Add the new regions to the REGIONS array

* Tests and add 2 more missing holidays (CH)
  • Loading branch information
OlinB committed Apr 2, 2024
1 parent 4c2c092 commit 7955989
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 3 deletions.
9 changes: 8 additions & 1 deletion lang/switzerland/fr/holidays.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{
"Neujahr": "Nouvel An",
"Neujahrs nächster tag": "Lendemain du Nouvel An",
"Berchtoldstag": "Saint-Berthold",
"Heilige Drei Könige": "Épiphanie",
"Neuenburger Republik tag": "Instauration de la République de Neuchâtel",
"Josefstag": "Saint-Joseph",
"Karfreitag": "Vendredi saint",
"Ostermontag": "Lundi de Pâques",
Expand All @@ -10,10 +12,15 @@
"Pfingstmontag": "Lundi de Pentecôte",
"Fronleichnam": "Fête-Dieu",
"Bundesfeier": "Fête nationale",
"Bundesfeier nächster tag": "Lendemain de la Fête nationale",
"Maria Himmelfahrt": "Assomption",
"Genfer Fasten": "Jeûne genevois",
"Buss- und Bettag": "Jeûne fédéral",
"Buss- und Bettag Montag": "Lundi du Jeûne fédéral",
"Allerheiligen": "Toussaint",
"Maria Empfängnis": "Immaculée Conception",
"Weihnachtstag": "Noël",
"Stephanstag": "Saint-Étienne"
"Weihnachtsnächstertag": "Lendemain de Noël",
"Stephanstag": "Saint-Étienne",
"Genf Republik tag": "Instauration de la République de Genève"
}
9 changes: 8 additions & 1 deletion lang/switzerland/it/holidays.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{
"Neujahr": "Capodanno",
"Neujahrs nächster tag": "Il giorno dopo Capodanno",
"Berchtoldstag": "San Silvestro",
"Heilige Drei Könige": "Epifania",
"Neuenburger Republik tag": "Istituzione della Repubblica di Neuchâtel",
"Josefstag": "San Giuseppe",
"Karfreitag": "Venerdì Santo",
"Ostermontag": "Lunedì di Pasqua",
Expand All @@ -10,10 +12,15 @@
"Pfingstmontag": "Lunedì di Pentecoste",
"Fronleichnam": "Corpus Domini",
"Bundesfeier": "Festa nazionale",
"Bundesfeier nächster tag": "Il giorno dopo la festa nazionale",
"Maria Himmelfahrt": "Assunzione",
"Genfer Fasten": "Jeûne genevois",
"Buss- und Bettag": "Digiuno federale",
"Buss- und Bettag Montag": "Digiuno federale Lunedì",
"Allerheiligen": "Ognissanti",
"Maria Empfängnis": "Immacolata Concezione",
"Weihnachtstag": "Natale",
"Stephanstag": "Santo Stefano"
"Weihnachtsnächstertag": "Il giorno dopo la festa di Natale",
"Stephanstag": "Santo Stefano",
"Genf Republik tag": "Istituzione della Repubblica di Ginevra"
}
56 changes: 55 additions & 1 deletion src/Countries/Switzerland.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ class Switzerland extends Country implements HasTranslations
'ch-bs',
'ch-be',
'ch-fr',
'ch-fr-c',
'ch-fr-r',
'ch-ge',
'ch-gl',
'ch-gr',
Expand All @@ -42,10 +44,14 @@ class Switzerland extends Country implements HasTranslations

private const NEW_YEARS_DAY = 'Neujahr';

private const NEW_YEARS_NEXT_DAY = 'Neujahrs nächster tag';

private const BERCHTOLDS_DAY = 'Berchtoldstag';

private const THREE_KINGS_DAY = 'Heilige Drei Könige';

private const NEUCHATEL_REPUBLIC_DAY = 'Neuenburger Republik tag';

private const SAINT_JOSEPHS_DAY = 'Josefstag';

private const GOOD_FRIDAY = 'Karfreitag';
Expand All @@ -62,18 +68,28 @@ class Switzerland extends Country implements HasTranslations

private const SWISS_NATIONAL_HOLIDAY = 'Bundesfeier';

private const SWISS_NATIONAL_HOLIDAY_NEXT_DAY = 'Bundesfeier nächster tag';

private const ASSUMPTION_DAY = 'Maria Himmelfahrt';

private const GENEVA_DAY_OF_FASTING = 'Genfer Fasten';

private const FEDERAL_DAY_OF_THANKSGIVING_REPENTANCE_AND_PRAYER = 'Buss- und Bettag';

private const FEDERAL_DAY_OF_THANKSGIVING_REPENTANCE_AND_PRAYER_MONDAY = 'Buss- und Bettag Montag';

private const ALL_SAINTS_DAY = 'Allerheiligen';

private const IMMACULATE_CONCEPTION = 'Maria Empfängnis';

private const CHRISTMAS_DAY = 'Weihnachtstag';

private const CHRISTMAS_NEXT_DAY = 'Weihnachtsnächstertag';

private const SAINT_STEPHENS_DAY = 'Stephanstag';

private const GENEVA_REPUBLIC_DAY = 'Genf Republik tag';

public function __construct(protected ?string $region = null)
{
if ($region !== null && ! in_array($region, self::REGIONS)) {
Expand Down Expand Up @@ -110,19 +126,26 @@ public function regionalHolidays(int $year): array
];

$regionallyDifferentHolidays = [
self::NEW_YEARS_NEXT_DAY => '01-02',
self::BERCHTOLDS_DAY => '01-02',
self::THREE_KINGS_DAY => '01-06',
self::NEUCHATEL_REPUBLIC_DAY => '03-01',
self::SAINT_JOSEPHS_DAY => '03-19',
self::GOOD_FRIDAY => $easter->subDays(2),
self::EASTER_MONDAY => $easter->addDay(),
self::LABOUR_DAY => '05-01',
self::WHIT_MONDAY => $easter->addDays(50),
self::CORPUS_CHRISTI => $easter->addDays(60),
self::SWISS_NATIONAL_HOLIDAY_NEXT_DAY => '08-02',
self::ASSUMPTION_DAY => '08-15',
self::GENEVA_DAY_OF_FASTING => (new CarbonImmutable('first sunday of September '.$year, 'Europe/Zurich'))->addDays(4), // Thursday after the first Sunday of September
self::FEDERAL_DAY_OF_THANKSGIVING_REPENTANCE_AND_PRAYER => new CarbonImmutable('third sunday of September '.$year, 'Europe/Zurich'),
self::FEDERAL_DAY_OF_THANKSGIVING_REPENTANCE_AND_PRAYER_MONDAY => (new CarbonImmutable('third sunday of September '.$year, 'Europe/Zurich'))->addDay(),
self::ALL_SAINTS_DAY => '11-01',
self::IMMACULATE_CONCEPTION => '12-08',
self::SAINT_STEPHENS_DAY => '12-26',
self::CHRISTMAS_NEXT_DAY => '12-26',
self::GENEVA_REPUBLIC_DAY => '12-31',
];

$currentRegion = match ($this->region) {
Expand Down Expand Up @@ -163,13 +186,26 @@ public function regionalHolidays(int $year): array
self::WHIT_MONDAY,
self::SAINT_STEPHENS_DAY,
],
'ch-fr' => [
'ch-fr', 'ch-fr-c' => [ // Catholic part of the canton is the default
self::GOOD_FRIDAY,
self::CORPUS_CHRISTI,
self::ASSUMPTION_DAY,
self::ALL_SAINTS_DAY,
self::IMMACULATE_CONCEPTION,
],
'ch-fr-r' => [ // Reformed part of the canton has special legislation for holidays
self::NEW_YEARS_NEXT_DAY,
self::GOOD_FRIDAY,
self::EASTER_MONDAY,
self::WHIT_MONDAY,
self::SAINT_STEPHENS_DAY,
],
'ch-ge' => [
self::GOOD_FRIDAY,
self::EASTER_MONDAY,
self::WHIT_MONDAY,
self::GENEVA_DAY_OF_FASTING,
self::GENEVA_REPUBLIC_DAY,
],
'ch-gl' => [
self::GOOD_FRIDAY,
Expand Down Expand Up @@ -198,6 +234,7 @@ public function regionalHolidays(int $year): array
self::SAINT_STEPHENS_DAY,
],
'ch-ne' => [
self::NEUCHATEL_REPUBLIC_DAY,
self::GOOD_FRIDAY,
self::LABOUR_DAY,
],
Expand Down Expand Up @@ -269,6 +306,7 @@ public function regionalHolidays(int $year): array
self::GOOD_FRIDAY,
self::EASTER_MONDAY,
self::WHIT_MONDAY,
self::FEDERAL_DAY_OF_THANKSGIVING_REPENTANCE_AND_PRAYER_MONDAY,
],
'ch-vs' => [
self::SAINT_JOSEPHS_DAY,
Expand Down Expand Up @@ -301,6 +339,22 @@ public function regionalHolidays(int $year): array
ARRAY_FILTER_USE_KEY
);

// Some holidays only happen in some years in some regions
if (in_array($this->region, ['ch-ge', 'ch-ne']) &&
(new CarbonImmutable("{$year}-01-01", 'Europe/Zurich'))->isSunday()) {
$regionalHolidays[self::NEW_YEARS_NEXT_DAY] = '01-02';
}

if (in_array($this->region, ['ch-ge']) &&
(new CarbonImmutable("{$year}-08-01", 'Europe/Zurich'))->isSunday()) {
$regionalHolidays[self::SWISS_NATIONAL_HOLIDAY_NEXT_DAY] = '08-02';
}

if (in_array($this->region, ['ch-ge', 'ch-ne']) &&
(new CarbonImmutable("{$year}-12-25", 'Europe/Zurich'))->isSunday()) {
$regionalHolidays[self::CHRISTMAS_NEXT_DAY] = '12-26';
}

return array_merge($regionalHolidays, $sharedHolidays);
}

Expand Down

0 comments on commit 7955989

Please sign in to comment.