Skip to content

Commit

Permalink
Switzerland - Fix Berchtolds Day (#688)
Browse files Browse the repository at this point in the history
  • Loading branch information
tinohager authored Sep 30, 2024
1 parent 4d38daf commit 8787ea3
Showing 1 changed file with 23 additions and 8 deletions.
31 changes: 23 additions & 8 deletions src/Nager.Date/HolidayProviders/SwitzerlandHolidayProvider.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Nager.Date.Extensions;
using Nager.Date.Helpers;
using Nager.Date.Models;
using Nager.Date.ReligiousProviders;
Expand Down Expand Up @@ -73,14 +74,6 @@ protected override IEnumerable<HolidaySpecification> GetHolidaySpecifications(in
HolidayTypes = HolidayTypes.Public
},
new HolidaySpecification
{
Date = new DateTime(year, 1, 2),
EnglishName = "St. Berchtold's Day",
LocalName = "Berchtoldstag",
HolidayTypes = HolidayTypes.Public,
SubdivisionCodes = ["CH-ZH", "CH-BE", "CH-LU", "CH-OW", "CH-GL", "CH-ZG", "CH-FR", "CH-SO", "CH-SH", "CH-TG", "CH-VD", "CH-NE", "CH-GE", "CH-JU"]
},
new HolidaySpecification
{
Date = new DateTime(year, 1, 6),
EnglishName = "Epiphany",
Expand Down Expand Up @@ -197,9 +190,31 @@ protected override IEnumerable<HolidaySpecification> GetHolidaySpecifications(in
this._catholicProvider.CorpusChristi("Fronleichnam", year).SetSubdivisionCodes("CH-LU", "CH-UR", "CH-SZ", "CH-OW", "CH-NW", "CH-ZG", "CH-AI", "CH-TI", "CH-VS", "CH-JU")
};

holidaySpecifications.AddIfNotNull(this.BerchtoldsDay(year));

return holidaySpecifications;
}

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, 12, 25).DayOfWeek == DayOfWeek.Sunday ||
new DateTime(year, 1, 1).DayOfWeek == DayOfWeek.Sunday)
{
subdivisionCodes.Add("CH-NE");
}

return new HolidaySpecification
{
Date = new DateTime(year, 1, 2),
EnglishName = "St. Berchtold's Day",
LocalName = "Berchtoldstag",
HolidayTypes = HolidayTypes.Public,
SubdivisionCodes = [.. subdivisionCodes]
};
}

/// <inheritdoc/>
public override IEnumerable<string> GetSources()
{
Expand Down

0 comments on commit 8787ea3

Please sign in to comment.