MH: FizHof Feiertage
This commit is contained in:
@@ -38,7 +38,31 @@ namespace FizHof.Service
|
||||
list.Add(new FeiertagDC { Datum = new DateTime(year, 12, 31), Name = "Silvester" });
|
||||
}
|
||||
|
||||
if (year >= 2023)
|
||||
{
|
||||
list.Add(new FeiertagDC { Datum = CalculateBussUndBettag(year), Name = "Buß- und Bettag" });
|
||||
list.Add(new FeiertagDC { Datum = new DateTime(year, 12, 24), Name = "Heiligabend" });
|
||||
list.Add(new FeiertagDC { Datum = new DateTime(year, 12, 31), Name = "Silvester" });
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
private static DateTime CalculateBussUndBettag(int year)
|
||||
{
|
||||
DateTime firstAdventSunday = CalculateFirstAdventSunday(year);
|
||||
DateTime bußUndBettag = firstAdventSunday.AddDays(-11); // Mittwoch vor dem 23. November
|
||||
|
||||
return bußUndBettag;
|
||||
}
|
||||
|
||||
private static DateTime CalculateFirstAdventSunday(int year)
|
||||
{
|
||||
DateTime christmas = new DateTime(year, 12, 25);
|
||||
int daysUntilSunday = ((int)christmas.DayOfWeek + 7 - (int)DayOfWeek.Sunday) % 7;
|
||||
DateTime firstAdventSunday = christmas.AddDays(-daysUntilSunday - 21); // 4 Wochen vor dem 1. Advent
|
||||
|
||||
return firstAdventSunday;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user