Code: Select all
Procedure LastDayOfMonth(m,y)
Select m
Case 1,3,5,7,8,10,12 ; Jan, Mar, May, Jul, Aug, Oct, Dec
d=31
Case 4,6,9,11 ; Apr, Jun, Sep, Nov
d=30
Default ; Feb
d=28+Bool((y%4=0 And (y%100<>0 Or y%400=0) And y<>3600))
EndSelect
ProcedureReturn d
EndProcedure
Debug LastDayOfMonth(2,2016) ; Outputs 29 because Feb 2016 is a Leap Year.