Compu-Calendar

Developer(s): Otis Imboden
Date: 1980
Type: Program
Platform(s): ZX80
Tags: Calendar

A three-part date program for the ZX80. Enter a month, day and four-digit year and it names the day of the week. Answer J at the next prompt and it prints the Julian day number, in millions, thousands and units; enter a second date and just press NEWLINE, and it prints the number of days between the two dates. Dates from January 1, 1 AD to February 2300 are handled.

Because the ZX80 has integer arithmetic only, the day count is sometimes shown as a thousands group 1000 too high followed by negative hundreds (2,-825 means 1,175 days); the article explains this. Enter 0 as the month to stop.

Published in Syntax December 1980 (Compu-Calendar).

Related Articles

This three-part program returns correct day name, changes Gregorian dates to corresponding Julian day numbers, and computes total days between any two dates from Jan. 1 AD to Feb. 2300.

Image Gallery

Source Code

  10 PRINT "COMPU-CAL"
  15 CLEAR
  20 PRINT "ENTER MO/DY/YEAR"
  30 INPUT M
  40 IF M=0 THEN STOP
  50 INPUT D
  55 INPUT Y
  57 CLS
  62 PRINT "YOUR DATE(";M;"/";D;"/";Y;")=";
  68 IF Y<1900 OR (Y=1900 AND M<3) THEN LET D=D+1
  69 IF Y<1800 OR (Y=1800 AND M<3) THEN LET D=D+1
  70 IF M>2 THEN GO TO 90
  80 LET Y=Y-1
  85 LET M=M+13
  87 GO TO 91
  90 LET M=M+1
  91 IF Y>2199 THEN LET D=D-1
  93 IF Y>2099 THEN LET D=D-1
 100 LET A=Y*3+7200
 110 LET B=(Y*6)+(M*3)+98
 120 LET C=(Y*5)+((M*6)/10)
 130 LET D=D+(Y/4)+C+2
 135 LET L=1+A/10000
 136 LET A=A-(10000*(A/10000))
 145 LET T=(A/10)+(B/100)+(D/1000)
 147 LET U=(100*(A-10*(A/10)))+(10*(B-(100*(B/100)))+(D-1000*(D/1000)))
 148 LET T=T+U/1000
 149 LET U=U-(1000*(U/1000))
 150 LET Z=2+L+(T*-1)+U
 155 LET Z=Z-(7*(Z/7))
 157 IF Z<0 THEN LET Z=Z+7
 158 GO SUB (Z*2)+160
 159 GO TO 179
 160 PRINT "SATUR";
 161 RETURN
 162 PRINT "SUN";
 163 RETURN
 164 PRINT "MON";
 165 RETURN
 166 PRINT "TUES";
 167 RETURN
 168 PRINT "WEDNES";
 169 RETURN
 170 PRINT "THURS";
 171 RETURN
 172 PRINT "FRI";
 173 RETURN
 174 GO TO 160
 179 PRINT "DAY"
 181 INPUT J$
 182 IF J$="J" THEN GO TO 195
 186 IF T-S<1 THEN GO TO 188
 187 PRINT T-S;",";
 188 PRINT U-W;" TOTAL DAYS"
 190 GO TO 15
 195 LET S=T
 197 LET W=U
 199 PRINT "JD=";L;",";T;",";U
 210 GO TO 20

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