Chapter 1 – Time (Interval Days)

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.

Interval Days

This program computes the precise interval in days, hours and minutes between two INPUT dates which may be between a few minutes to centuries apart. The important part of the program is from Line 10, where an MJD is worked out for each INPUT date. Each date has a unique JD and full account is taken of leap years (February 29) at 4, 100 and 400 year intervals. If an invalid date is entered this is corrected to the true date, for the purposes of computing the interval.

a) 1983 Feb 33 (invalid) = 1983 Mar 5 (valid)
b) 1984 Feb 33 (invalid) = 1984 Mar 4 (valid)

The two INPUT dates may be entered in either order. Line 70 ensures that the result is always positive. The month should be entered numerically – January = 1, February – 2, etc. Figure 1.3 shows typical results.

Figure 1.3

9 REM ***********************
10 REM *****Interval Days*****
11 REM ***********************
20 DIM j(2): FOR x=1 TO 2
40 INPUT “Year “;y;” Month “;m;” Day “;d,”Hour (0-23) “;h;” min “;mn
50 PRINT y;”/”;m;”/”;d;” “;h;”h “;mn;”m”: LET d=d+h/24+mn/1400
60 GO SUB 1000: NEXT x
70 LET day=ABS (j(1)-j(2))
80 PRINT “Interval days=”,day
90 LET hour=24*(day-INT day): LET min=60*(hour-INT hour)
100 PRINT ,INT day;”d “;INT hour;”h “;INT min;”m””: GO TO 1
1010 LET yy=y/100: LET y1=INT yy: LET yt=y/400: LET y4=INT yt
1030 LET j(x)=d+INT (365.25*(y-(m<3)))+INT (30.6001*(m+1+12*(m<3)))-y1+y4+(yy=y1 AND yty4 AND m<3): RETURN
9900 REM ***********************
9990 SAVE “intdays”

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