05-05-2022, 04:49 AM
(This post was last modified: 05-05-2022, 04:54 PM by dcromley.
Edit Reason: added "m d"
)
It seems like it was just a few days ago that I posted about this
https://staging.qb64phoenix.com/showthread.php?tid=65
So I changed it to take into account leap-years. Very interesting.
The big "Int" statement starts the year with March, and Jan & Feb get moved to 13 and 14. Then the MOD 365 brings them back.
This code has just numerics; no strings. Great fun. Thanks.
https://staging.qb64phoenix.com/showthread.php?tid=65
So I changed it to take into account leap-years. Very interesting.
The big "Int" statement starts the year with March, and Jan & Feb get moved to 13 and 14. Then the MOD 365 brings them back.
This code has just numerics; no strings. Great fun. Thanks.
Code: (Select All)
Print "m d", 2022, 2024, 2100, 2400
For m = 1 To 12
Print m; 1, func(m, 1, 2022), func(m, 1, 2024), func(m, 1, 2100), func(m, 1, 2400)
Next m
Print 12; 31, func(12, 31, 2022), func(12, 31, 2024), func(12, 31, 2100), func(12, 31, 2400)
Function func (m, d, y)
ret = d + Int((295 + 153 * ((m + 9) Mod 12) + 2) / 5) Mod 365
If y Mod 4 = 0 And (y Mod 100 <> 0 Or y Mod 400 = 0) And m > 2 Then ret = ret + 1
func = ret
End Function