Chapter 1 – Time (Spectrum Calendar)

Measuring time, different calendars
Spectrum Calendar, prints a calendar for any year after 1582
Julian Date, works out the Julian Day number for any date
Julian Calendar, prints a complete Julian Day calendar for any month of any year
Day of the Week, identifies the day of the week for any date
Interval Days, the interval between any two dates from a few minutes to centuries apart
Local Sidereal Time, calculates ‘star time’ for any date and hour
Reaction Timer, find out your reaction time to get accurate readings.

Spectrum Calendar

This program PRINTs to the screen a colourful calendar, four months at a time, for any selected year after 1582 – the year the Gregorian or modern Reform Calendar was introduced.

The program
The essential part of the program is Line 10 where the Julian Day number as it is called, is calculated via the variable j(m) for the first day of each month, using the first FOR/NEXT m loop. This is later compared (in Line 130) with the Julian Day number for each day using the variable jx against the Julian Day number for the first day of the next month:

130 IF jx = j(m+1) THEN GOTO 190

ie start a new month. Thus each month has the correct number of days and full account is taken of leap years (February 29th) at 4, 100 and 400 year intervals.

The brevity of the Julian Day number routine as a simple one-liner is achieved with Bolean Logic in that the portions in brackets are only calculated if true, returning a nil value if false. Line 140 identifies the day of the week, eg Sunday, Monday.

Line 220 is a conditional GOTO, for displaying the remaining two pages of the calendar starting with May and September. It is important that the rather odd Lines 311 and 313 are not amended, otherwise the program will not proceed beyond the first page covering January to April. The value of the second FOR/NEXT m loop (Line 60) is upgraded via the variable a in Line 311. The conditional GOTO in Line 220 repeats this m loop until m=12+1 (rather strangely it is always + 1 more than the current value of the loop) for December so the program will GOTO 313 (300+13) and is reRUN.

The REM statements identify the general structure of the program. Most of them are concerned with the complex screen display and formatting Each Julian Day number is shown briefly on the bottom line of the screen and, as the Julian Day begins at noon (this will be explained in the Julian Date program later in this chapter) a value of 0.5 appears in each number See Figure 1.1 for a sample page from the Spectrum calendar.

The program contains a couple of useful tips. Firstly, the use of the n$ at the beginning of the program to serve the dual purpose of titling the LLISTing and the screen display. Secondly, reserving space via DIM a$ (30) for use in Line 40:

40 PRINT… d$ + a$ + d$….

instead of the more usual

PRINT… d$ + ” 30 blank spaces ” + d$

where the d$ contains the initial letters of the days of the week from character 37 onwards. (See Line 6 for the complete contents of the d$.) The rest of the d$ holds the month names.

Line 210 contains an option to COPY the screen display one page at a time via the INKEY$ command.

5 DIM a$(30): DIM j(12): DIM e$(12,3): LET a=1
6 LET d$=”JanFebMarAprMayJunJulAugSepOctNovDecsMTWTFS”
7 INPUT “Year=”;y: IF y<1583 THEN GO TO 7
8 LET yy=y/100: LET y1=INT yy: LET yt=y/400: LET y4=INT yt
10 FOR m=1 TO 12: LET j(m)=INT (365.25*(y-(m<3)))+INT (30.6001*(m+1+12*(m<3)))-y1+y4+1720996.5+1+(1 AND yy=y1 AND yty4 AND m<3)
12 LET e$(m)=d$(m*3-2 TO m*3)
15 NEXT m
20 CLS : LET z=1: LET zz=0
30 FOR n=1 TO 16: PRINT PAPER n/2-1; INK 9;(” ” AND n=9)+n$(n)+” “;: NEXT n
40 PRINT ‘y: FOR f=0 TO 1: FOR n=1 TO 7: PRINT PAPER 7-n; INK 9;d$(36+n)+a$+d$(36+n): NEXT n: PRINT ”: NEXT f
50 PRINT AT 2,9;e$(a);AT 2,21;e$(a+1);AT 11,9;e$(a+2);AT 11,22;e$(a+3)
60 FOR m=a TO a+3: LET xx=1
80 IF m=3 OR m=4 OR m=7 OR m=8 OR m=11 OR m=12 THEN LET xx=10: LET zz=0
90 IF m=3 OR m=7 OR m=11 THEN LET z=1
100 FOR d=1 TO 31
110 LET jx=j(m)+d-1
120 IF m=12 THEN GO TO 140
130 IF jx=j(m+1) THEN GO TO 190
140 LET q=INT (jx-5)-7*INT ((jx-5)/7)+1
150 LET x=q+1: IF q=1 THEN LET x=x-q+1: LET z=z+3
160 PRINT AT x+xx,z+zz; PAPER 7-q;(” ” AND m/2=INT (m/2))+(” ” AND d<10); INK 9;d
170 PRINT AT 21,0;”Julian Day no=”;jx
180 NEXT d
190 NEXT m
200 PRINT #0;”Press z for COPY, c to continue”: PAUSE 0
220 GO TO 300+m
310 LET a=a+4: GO TO 20
313 RUN

Figure 1.1
Sample page from calendar.


A video of this program running can be found here:

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s