Feiertagsberechnung

This commit is contained in:
2023-10-16 08:45:43 +02:00
parent 64aef365bf
commit 72ab324a0f

View File

@@ -1,4 +1,6 @@
Public Class cFeiertage
Imports System.Runtime.InteropServices.ComTypes
Public Class cFeiertage
Private _Year As Integer
Private _Ostern As Date
@@ -65,15 +67,23 @@
Public Function GetLastyDayInyMonth(ByVal day As DayOfWeek, ByVal month As Integer, ByVal year As Integer) As DateTime
' Create a start date for the 1st day of the month
Dim startDate As DateTime = New DateTime(year, month, 1)
' Create a start date for the last weekday of the month
Dim startDate As DateTime
While startDate.DayOfWeek <> day
startDate = startDate.AddDays(1)
If (month < 12) Then
startDate = New DateTime(year, month + 1, 1)
Else
startDate = New DateTime(year + 1, 1, 1)
startDate = startDate.AddDays(-1)
End If
While (startDate.DayOfWeek <> day)
startDate = startDate.AddDays(-1)
End While
Return startDate
End Function