mmbasic:compact_quick_day_of_week_function_with_historical_capability
Compact Quick Day Of Week function with historical capability
Fast,compact Day of the Week function that correctly handles pre 2001 dates correctly
credit: TBS user MicroBlocks, the original thread can be seen here: https://www.thebackshed.com/forum/ViewTopic.php?TID=6235&KW=weekday&PN=1&TPN=1
It has been tweaked here to add typing to the function and local variables
Function DayOfWeek(year As Integer,month As Integer,day As Integer) As Integer ' sun mon tue wed thu fri sat ' 0 1 2 3 4 5 6 local integer a,m,y a = int((14-month)/12) m = month + 12*a - 2 y = year - a DayOfWeek = (day + y + int(y/4)-int(y/100)+int(y/400)+int(31*m/12)) mod 7 End Function
mmbasic/compact_quick_day_of_week_function_with_historical_capability.txt · Last modified: 2025/02/10 15:32 by gerry