Classic Computer Magazine Archive COMPUTE! ISSUE 25 / JUNE 1982 / PAGE 151

VIC's Perpetual Calendar

Robert Lewis
Decatur, IL

Have you ever wanted to see a calendar for next year? Last year? Or the year you were born? This program is able to produce a correct calendar for any year after 1900. There are other starting years in program lines 10-60. These years are 1950, 1800, and 1582; the year today's calendar was started.

To change the starting year, delete the REM statement from the year wanted and the next following line. Be sure to add REM statements to the old lines or you may get an error when the program is run.

To use the program simply INPUT the full year (example: 1982) when asked "YEAR WANTED?". After entering the date, the program uses a loop to find what day of the week January first falls on in that year. A large difference in the entered and starting years may cause a delay of several seconds.

When it leaves the loop, it checks if it is a leap year and adjusts the count. There are several checks for leap year by the formula: IF Y/4 = INT (Y/4)THEN...

The last half of the program is devoted to displaying each month on the screen. The VIC's 22 character screen is an asset! The display consists of (starting from the top) the year, the number of days passed and left, the month, the days of the week and, finally, the dates. February and the days left arid passed are automatically compensated for in leap years. All calendars start with January and each preceding month is displayed by pressing any key but (Fl). When (Fl) is pressed, the program asks for another "YEAR WANTED?" with a statement about the starting year. This also occurs when you enter a date before the starting year. At December, when you press a key, the program goes to January of the next year.

10 REM REMOVE REMARK FROM YEAR DESIRED AND ADJACENT LINE
15 REM AND ADD TO THE OLD LINES
20 REMYY = 1800
21 REMCC = 2
30 YY = 1900
31 CC = 1
40 REMYY = 1950
41 REMCC = 0
50 REMYY = 1582
60 REMCC = 2
65 REM INSTRUCTIONS
70 POKE 36879, 8
80 B1$ = " VIC'S " : B2$ = " PERPETUAL ~ " : B3$ = " CALENDAR "
90 PRINT"{CLEAR}" : PRINT : PRINT"{REV}{GRN}~"
100 PRINT"{REV} _"
110 PRINT"{REV} _"
120 FOR I = 1 TO 13 : PRINT TAB(I-1)"_{REV} "MID$(B3$, I, 1);"
        ";MID$(B2$, I, 1);" ";MID$ (B1$, I, 1);" _{0FF}
125 NEXT I
130 PRINT"{WHT}BY : {GRN}";SPC(I-4); "_{REV}~{OFF}"
140 PRINTSPC(I);"_{REV} {OFF}"
150 PRINT" {WHT} ROBERT LEWIS{GRN}" ;SPC(I-11);"_{REV}"
160 PRINT"{HOME}" : PRINT : PRINT : PRINT";{REV}{YYEL}"SPC(15);YY;"{LEFT} {OFF}" : PRINTSPC(17) "%"
165 PRINTTAB(15);"{REV} ???? {OFF}"
170 PRINT : PRINT TAB(15)"{CYN}INST?"
180 GETA$ : IFA$ = ""THEN 180
190 IFA$ = "N" THEN 330
200 PRINT"{GRN}{CLEAR} THIS PROGRAM MAKES ~ UP A CALENDAR FOR ANY"
210 PRINT"YEAR {RED}{REV}AFTER";YY;"{OFF}."
220 PRINT : PRINT"{CYN} OTHER STARTING YEARS ARE IN LINES 10-60."
230 PRINT : PRINT"{BLU} TO ENTER ANOTHER CALENDAR YEAR PRESS {REV}F1{OFF}."
240 PRINT : PRINT"{YEL} THE YEAR ALWAYS BEGINS IN JANUARY. TO"
250 PRINT"SEE THE FOLLOWING MONTHS PRESS ANY OTHER KEY.";
260 PRINT" {PUR}(IN DECEMBER THE CALENDAR GOES TO THE NEXT YEAR)" : PRINT
270 INPUT"{WHT}YEAR WANTED" ;Y
280 DA = 365 : IFY/4 = INT(Y/4)THENDA = 366
290 H = 0 : DB = DA
300 IFY>YY THEN 360
310 RESTORE
320 K = 0
330 PRINT"{CLEAR}{WHT}I CAN'T START BEFORE"YY
340 POKE36879,8
350 GOTO270
355 REM YEAR LOOP
360 Z = Y - YY : C = CC
370 FOR I = 1 TO Z
380 C = C + 1 : YX = YY + I
390 IF YX/4 = INT(YX/4)THEN C = C + 1
400 IFC> = 7 THEN C = C - 7
410 NEXT I
420 IF Y/4 = INT(Y/4)THEN C = C - 1 : IF C < 0 THEN C = 7 + C425 REM READS MONTH
430 READM$, M : S = LEN(M$)
435 REM ADJUST FOR LEAP YEAR
440 IF M = 3 AND (Y/4 = INT(Y/4)) THEN M=2
450 IF C < 7 OR C = 7 THEN C = C - 7
460 B = C
490 REM PRINTS MONTH
500 PRINT" {BLK}" : K = K + 1 : IF K = 6 THEN K = 0
510 POKE 36879, 40 + (K * 16)
520 PRINT" {CLEAR}" : PRINT" {REV}" TAB (8) ; Y ; " {LLEFT} {OFF}"
530 PRINTTAB(1) ; H ; TAB(16) ; DB
540 PRINTTAB(10 - (S/2)) "0" ; : FOR I = 1 TO S : PRINT"@" ; : NEXT I : PRINT"."
550 PRINTTAB(10 - (S/2)) "] {REV}" ; M$ ; " {OFF}]"
560 PRINTTAB(10 - (S/2))"-" ; : FOR I = 1 TO S : PRINT"@" ; : NEXT I : PRINT " = "
570 PRINT : PRINT" S M T W T F S" : PRINT
580 PRINTSPC(3 * B) ;
590 FOR I = 1 TO 31 - M
600 PRINT I ; : I FI > 9 THEN PRINT" {LEFT}" ;
610 IF POS(0) > 19 THEN PRINT : PRINT
620 NEXT I : PRINT
700 GET X$ : IFX$ = "" THEN 700
705 REM NEW DATE WANTED
710 IF X$ = "{F1}" THEN 310
715 REM SETS UP NEXT
716 REM MONTH OR YEAR
720 C = B + 3 - M
730 IF M$ <> "DECEMBER" THEN 790
740 RESTORE
750 Y = Y + 1
760 H = O : DB = 365 : IF Y/4 = INT(Y/4)THEN DB = 366
770 DA = DB
780 GOTO 430
790 DB = DB - (31 - M) : H = DA - DB
800 GOTO 430
810 END
1000 DATA JANUARY, 0, FEBRUARY, 3, MARCH, 0, APRIL, 1, MAY, 0, JUNE, 1, JULY, 0
1010 DATA AUGUST, 0, SEPTEMBER, 1, OCTOBER, 0, NOVEMBER, 1 ,DECEMBER, 0