diff --git a/src/Nager.Date/HolidayProviders/SwitzerlandHolidayProvider.cs b/src/Nager.Date/HolidayProviders/SwitzerlandHolidayProvider.cs index 5e2b268e..b6f91544 100644 --- a/src/Nager.Date/HolidayProviders/SwitzerlandHolidayProvider.cs +++ b/src/Nager.Date/HolidayProviders/SwitzerlandHolidayProvider.cs @@ -1,3 +1,4 @@ +using Nager.Date.Extensions; using Nager.Date.Helpers; using Nager.Date.Models; using Nager.Date.ReligiousProviders; @@ -73,14 +74,6 @@ protected override IEnumerable 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", @@ -197,9 +190,31 @@ protected override IEnumerable 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(["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] + }; + } + /// public override IEnumerable GetSources() {