Monthly Calendar

Author(s): Herb Cohen
Publication: Syntax
Pub Details: Syntax/Syntax ZX80 v3 n9 (Volume 3, Issue 9)
Date: September 1982
Pages: 5

This 8K/16K program displays a calendar for any month in any particular year. It uses equations developed by Zeller, the astronomer, to determine the day that the desired month begins on. To run, simply type in the program, press RUN, and select the desired month and year for the calendar. This program accepts the data and determines the name of the month (lines 1-210). Next the program determines the number of days in the requested month and checks for a leap year (lines 240-420). Finally the program displays the final calendar. To display another month, simply press RUN again and enter the necessary information. There are no special instructions for exiting; the program does so automatically.

   1 REM CALENDER
5 FAST
10 PRINT "ENTER MONTH (1 TO 12)"
20 INPUT M
30 PRINT "ENTER YEAR"
40 INPUT Y
60 LET D=1
70 LET MON=M
80 LET YEAR=Y
90 DIM A$(12,9)
100 LET A$(1)="JANUARY "
110 LET A$(2)="FEBRUARY "
120 LET A$(3)="MARCH "
130 LET A$(4)="APRIL "
140 LET A$(5)="MAY "
150 LET A$(6)="JUNE "
160 LET A$(7)="JULY "
170 LET A$(8)="AUGUST "
180 LET A$(9)="SEPTEMBER"
190 LET A$(10)="OCTOBER "
200 LET A$(11)="NOVEMBER "
210 LET A$(12)="DECEMBER "
220 DIM A(42)
230 LET END=30
240 IF M=1 OR M=3 OR M=5 OR M=7 OR M=8 OR M=10 OR M=12 THEN LET END=31
250 IF M=2 THEN LET END=28
260 LET LEAP=0
270 IF Y/4=INT (Y/4) AND Y/100<>INT (Y/100) THEN LET LEAP=1
280 IF Y/400=INT (Y/400) THEN LET LEAP=1
300 IF M=2 AND LEAP=1 THEN LET END=29
310 IF M=1 OR M=2 THEN LET M=M+12
320 IF M=13 OR M=14 THEN LET Y=Y-1
330 LET R=D+2*M+2+INT ((3*M+3)/5)+INT (Y/4)+Y-INT (Y/100)+INT (Y/400)
340 LET NUM=(R/7-INT (R/7))*7
350 LET NUM=INT (NUM+.5)
360 LET START=NUM
370 IF NUM=0 THEN LET START=7
380 LET DAY=1
390 FOR P=START TO 42
400 LET A(P)=DAY
410 LET DAY=DAY+1
420 NEXT P
430 CLS
440 PRINT TAB 10;A$(MON);"B";YEAR
450 PRINT
460 PRINT " SUN MON TUE WED THU FRI SAT"
470 FOR R=0 TO 5
480 FOR C=1+R*7 TO 7+R*7
490 LET CC=C-R*7
500 IF A(C)=0 THEN PRINT TAB (4*CC);"B";
510 IF A(C)=0 THEN GOTO 550
520 IF A(C)>END THEN PRINT TAB (4*CC);"B";
530 IF A(C)>END THEN GOTO 550
540 PRINT TAB (4*CC);A(C);
550 NEXT C
560 NEXT R
570 STOP
SYNTACTIC SUM: 19602, 8K

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.