Julian Date

Developer(s): Jack Hodgson
Date: 1983
Type: Program
Platform(s): ZX81, TS 1000
Tags: Calendar

Converts a calendar date to a day number counted from 1 March 1900 (day 0), which the article calls a Julian date. Subtracting two such numbers gives the days between dates: June 13, 1983 is 30419 and April 9, 1983 is 30354, 65 days apart.

RUN it and answer YEAR?, MONTH? and DAY? (numbers). Valid from 1 March 1900 to the end of February 2100.

Corrected as published the next month: Dave Miller pointed out that lines 120 and 140 were wrong (and that 2000 is a leap year, which the editor’s addition to the article had denied). This version has his two lines; as first printed, January and February dates stop with report 2 (M not set) or reuse an old value, and some other dates come out one day high.

Published in the BCS Sinclair-Timex User Group Newsletter July 1983 (Does Anybody Really Know What Day It Is?); correction in the August 1983 issue (Time-Out).

Image Gallery

Source Code

  10 PRINT "TO COMPUTE JULIAN DATE (BASE=1 MARCH 1900) YEAR? ";
  20 INPUT YR
  30 PRINT YR
  40 PRINT "MONTH? ";
  50 INPUT MTH
  60 PRINT MTH
  70 PRINT "DAY? ";
  80 INPUT DAY
  90 PRINT DAY
 100 LET Y=YR-1900
 110 IF MTH>2 THEN GOTO 170
 120 LET M=MTH+9
 130 LET Y=Y-1
 140 LET JDATE=INT((1461*Y)/4)+INT((153*M+2)/5)+DAY-1
 150 PRINT MTH;"/";DAY;"/";YR;" = JULIAN DATE ";JDATE
 160 STOP
 170 LET M=MTH-3
 180 GOTO 140

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