05-04-2022, 07:10 PM
Actually, I'm going to post this demo to demonstrate how to calculate the day (1-366) in leap year and non-leap year calendar periods. I believe your deo only provides the accumulative days in a leap year event, but correct me if I'm wrong.
Note that 1700, 1800 and 1900 were not a leap year, but 2000 was.
I think Steve even has a one-liner for leap year calculation.
Anyway, feel free to add any of this info / code to your routine if you like, update /edit your code, etc. I don't get bent because my post no longer represents changes another poster makes, unless of course they are doing it to make me look stupid. My wife takes offense at that.... because it's her job.
Pete
Code: (Select All)
INPUT "month-day-year as 'xx-xx-xxxx': ", a$
month$ = LEFT$(a$, 2)
day$ = MID$(a$, 4, 2)
a1 = VAL(MID$(a$, 7, 4)): ly = 0
IF a1 MOD 4 = 0 AND VAL(month$) > 2 THEN ' Check to add a day if leap year.
IF a1 MOD 100 = 0 THEN
IF a1 MOD 400 = 0 THEN ly = 1
ELSE
ly = 1
END IF
END IF
datenum$ = _TRIM$(STR$(VAL(MID$("000031059090120151181212243273304334", VAL(month$) * 3 - 2, 3)) + VAL(day$) + ly))
datenum$ = MID$("00", LEN(datenum$)) + datenum$
PRINT a$
PRINT month$
PRINT day$
PRINT datenum$;: IF ly THEN PRINT " Leap year day included."
SLEEP
CLS
RUN
Note that 1700, 1800 and 1900 were not a leap year, but 2000 was.
I think Steve even has a one-liner for leap year calculation.
Anyway, feel free to add any of this info / code to your routine if you like, update /edit your code, etc. I don't get bent because my post no longer represents changes another poster makes, unless of course they are doing it to make me look stupid. My wife takes offense at that.... because it's her job.
Pete