# Chapter 1 – Time (Interval Days)

## 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.

Example
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”