Skip to content

Commit

Permalink
Switzerland - Fix holiday list (#725)
Browse files Browse the repository at this point in the history
  • Loading branch information
tinohager authored Dec 2, 2024
1 parent 967c2be commit 0a02395
Showing 1 changed file with 68 additions and 24 deletions.
92 changes: 68 additions & 24 deletions src/Nager.Date/HolidayProviders/SwitzerlandHolidayProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ protected override IEnumerable<HolidaySpecification> GetHolidaySpecifications(in
Date = new DateTime(year, 6, 29),
EnglishName = "Saints Peter and Paul",
LocalName = "Peter und Paul",
HolidayTypes = HolidayTypes.Public,
HolidayTypes = HolidayTypes.Observance,
SubdivisionCodes = ["CH-TI"]
},
new HolidaySpecification
Expand All @@ -105,22 +105,6 @@ protected override IEnumerable<HolidaySpecification> GetHolidaySpecifications(in
HolidayTypes = HolidayTypes.Public
},
new HolidaySpecification
{
Date = new DateTime(year, 8, 15),
EnglishName = "Assumption of the Virgin Mary",
LocalName = "Maria Himmelfahrt",
HolidayTypes = HolidayTypes.Public,
SubdivisionCodes = ["CH-LU", "CH-UR", "CH-SZ", "CH-OW", "CH-NW", "CH-ZG", "CH-FR", "CH-SO", "CH-BL", "CH-AI", "CH-GR", "CH-AG", "CH-TI", "CH-VS", "CH-JU"]
},
new HolidaySpecification
{
Date = new DateTime(year, 11, 1),
EnglishName = "All Saints' Day",
LocalName = "Allerheiligen",
HolidayTypes = HolidayTypes.Public,
SubdivisionCodes = ["CH-LU", "CH-UR", "CH-SZ", "CH-OW", "CH-NW", "CH-GL", "CH-ZG", "CH-FR", "CH-SO", "CH-AI", "CH-SG", "CH-GR", "CH-AG", "CH-TI", "CH-VS", "CH-JU"]
},
new HolidaySpecification
{
Date = new DateTime(year, 12, 25),
EnglishName = "Christmas Day",
Expand Down Expand Up @@ -151,6 +135,14 @@ protected override IEnumerable<HolidaySpecification> GetHolidaySpecifications(in
HolidayTypes = HolidayTypes.Public,
SubdivisionCodes = ["CH-VD"]
},
new HolidaySpecification
{
Date = new DateTime(year, 12, 31),
EnglishName = "Restoration Day",
LocalName = "Restauration de la République",
HolidayTypes = HolidayTypes.Public,
SubdivisionCodes = ["CH-GE"]
},
this._catholicProvider.GoodFriday("Karfreitag", year).SetSubdivisionCodes("CH-ZH", "CH-BE", "CH-LU", "CH-UR", "CH-SZ", "CH-OW", "CH-NW", "CH-GL", "CH-ZG", "CH-FR", "CH-SO", "CH-BS", "CH-BL", "CH-SH", "CH-AR", "CH-AI", "CH-SG", "CH-GR", "CH-AG", "CH-TG", "CH-VD", "CH-NE", "CH-GE", "CH-JU"),
this._catholicProvider.AscensionDay("Auffahrt", year),
};
Expand All @@ -161,6 +153,8 @@ protected override IEnumerable<HolidaySpecification> GetHolidaySpecifications(in
holidaySpecifications.AddRangeIfNotNull(this.WhitMonday(year));
holidaySpecifications.AddRangeIfNotNull(this.EasterMonday(year));
holidaySpecifications.AddRangeIfNotNull(this.Epiphany(year));
holidaySpecifications.AddRange(this.AssumptionOfTheVirginMary(year));
holidaySpecifications.AddRange(this.AllSaintsDay(year));
holidaySpecifications.AddIfNotNull(this.BerchtoldsDay(year));
holidaySpecifications.AddRangeIfNotNull(this.SaintJosephsDay(year));
holidaySpecifications.AddRangeIfNotNull(this.CorpusChristi(year));
Expand Down Expand Up @@ -194,12 +188,37 @@ private HolidaySpecification[] Epiphany(int year)
];
}

private HolidaySpecification[] AssumptionOfTheVirginMary(int year)
{
var englishName = "Assumption of the Virgin Mary";
var localName = "Maria Himmelfahrt";

return
[
new HolidaySpecification
{
Date = new DateTime(year, 8, 15),
EnglishName = englishName,
LocalName = localName,
HolidayTypes = HolidayTypes.Public,
SubdivisionCodes = ["CH-LU", "CH-UR", "CH-SZ", "CH-OW", "CH-NW", "CH-ZG", "CH-FR", "CH-SO", "CH-AG", "CH-TI", "CH-VS"]
},
new HolidaySpecification
{
Date = new DateTime(year, 8, 15),
EnglishName = englishName,
LocalName = localName,
HolidayTypes = HolidayTypes.Observance,
SubdivisionCodes = ["CH-AI", "CH-JU"]
}
];
}

private HolidaySpecification BerchtoldsDay(int year)
{
var subdivisionCodes = new List<string>(["CH-BE", "CH-FR", "CH-SH", "CH-AG", "CH-TG", "CH-VD"]);

if (new DateTime(year, 1, 1).DayOfWeek == DayOfWeek.Sunday ||
new DateTime(year, 12, 25).DayOfWeek == DayOfWeek.Sunday)
if (new DateTime(year, 1, 1).DayOfWeek == DayOfWeek.Sunday)
{
subdivisionCodes.Add("CH-NE");
}
Expand Down Expand Up @@ -240,6 +259,32 @@ private HolidaySpecification[] SaintJosephsDay(int year)
];
}

private HolidaySpecification[] AllSaintsDay(int year)
{
var englishName = "All Saints' Day";
var localName = "Allerheiligen";

return
[
new HolidaySpecification
{
Date = new DateTime(year, 11, 1),
EnglishName = englishName,
LocalName = localName,
HolidayTypes = HolidayTypes.Public,
SubdivisionCodes = ["CH-LU", "CH-UR", "CH-SZ", "CH-OW", "CH-NW", "CH-GL", "CH-ZG", "CH-FR", "CH-SO", "CH-SG", "CH-GR", "CH-AG", "CH-TI", "CH-VS"]
},
new HolidaySpecification
{
Date = new DateTime(year, 11, 1),
EnglishName = englishName,
LocalName = localName,
HolidayTypes = HolidayTypes.Observance,
SubdivisionCodes = ["CH-AI", "CH-JU"]
}
];
}

private HolidaySpecification[] EasterMonday(int year)
{
var localName = "Ostermontag";
Expand Down Expand Up @@ -295,15 +340,15 @@ private HolidaySpecification[] ImmaculateConception(int year)
EnglishName = englishName,
LocalName = localName,
HolidayTypes = HolidayTypes.Public,
SubdivisionCodes = ["CH-LU", "CH-UR", "CH-SZ", "CH-OW", "CH-NW", "CH-ZG", "CH-FR", "CH-SO", "CH-AG", "CH-TI", "CH-VS"]
SubdivisionCodes = ["CH-UR", "CH-OW", "CH-NW", "CH-ZG", "CH-FR", "CH-AG", "CH-VS"]
},
new HolidaySpecification
{
Date = new DateTime(year, 12, 8),
EnglishName = englishName,
LocalName = localName,
HolidayTypes = HolidayTypes.Observance,
SubdivisionCodes = ["CH-AI", "CH-JU"]
SubdivisionCodes = ["CH-AI", "CH-JU", "CH-LU", "CH-SZ", "CH-TI"]
}
];
}
Expand All @@ -321,7 +366,7 @@ private HolidaySpecification[] LabourDay(int year)
EnglishName = englishName,
LocalName = localName,
HolidayTypes = HolidayTypes.Public,
SubdivisionCodes = ["CH-ZH", "CH-SO", "CH-BS", "CH-BL", "CH-SH", "CH-AG", "CH-NE", "CH-JU"]
SubdivisionCodes = ["CH-ZH", "CH-SO", "CH-BS", "CH-BL", "CH-SH", "CH-NE", "CH-JU"]
},
new HolidaySpecification
{
Expand All @@ -347,8 +392,7 @@ private HolidaySpecification[] StephensDay(int year)
subdivisionCodes.AddRange(["CH-AR", "CH-AI"]);
}

if (new DateTime(year, 1, 1).DayOfWeek == DayOfWeek.Sunday ||
new DateTime(year, 12, 25).DayOfWeek == DayOfWeek.Sunday)
if (new DateTime(year, 12, 25).DayOfWeek == DayOfWeek.Sunday)
{
subdivisionCodes.Add("CH-NE");
}
Expand Down

0 comments on commit 0a02395

Please sign in to comment.