Hi Folks,
was watching this fascinating video this weekend:
"Implementing Fast Calendar Algorithms"
https://www.youtube.com/watch?v=J9KijLyP-yg
And i caught myself thinking: Huh? I've been doing the "classical" way all that time
So i searched through the forums here, and pretty much every result showed the "classical" way
So i sat down and rewrote their C/C++-Code in VB6/VBA
Yes, i'm aware, that there is a "Version" for LastDayOfMonth with a lookup-Array, but in VB6/VBA we would have to initialize that Array first (since constant arrays are not supported),
so i refrained from showing it here
Wouldn't mind reviews or Performance-Test-Results
Comments welcome
was watching this fascinating video this weekend:
"Implementing Fast Calendar Algorithms"
https://www.youtube.com/watch?v=J9KijLyP-yg
And i caught myself thinking: Huh? I've been doing the "classical" way all that time
So i searched through the forums here, and pretty much every result showed the "classical" way
So i sat down and rewrote their C/C++-Code in VB6/VBA
Code:
Public Function IsLeapYear(ByVal AYear As Long) As Boolean
If AYear Mod 100 <> 0 Then
IsLeapYear = (AYear Mod 4) = 0
Else
IsLeapYear = (AYear Mod 16) = 0
End If
End Function
'Could also use ... As Integer
Public Function LastDayOfMonth(ByVal AYear As Long, ByVal AMonth As Long) As Long
If AMonth = 2 Then
If IsLeapYear(AYear) Then
LastDayOfMonth = 29
Else
LastDayOfMonth = 28
End If
Else
LastDayOfMonth = 30 Or (9 * AMonth \ 8)
End If
End Function
so i refrained from showing it here
Wouldn't mind reviews or Performance-Test-Results
Comments welcome