--- title: "Calendar and Clock" id: 72287 type: "computer_media" slug: "calendar-and-clock" url: "http://localhost/computer_media/calendar-and-clock/" markdown_url: "http://localhost/computer_media/calendar-and-clock.md" published_at: "2026-10-23T07:47:20+00:00" modified_at: "2026-10-23T07:47:20+00:00" author: "David Anderson" featured_image: url: "http://localhost/wp-content/uploads/2026/10/calclock-2.png" excerpt: "Prints a calendar for any month from 1700 to 1999 and runs an on-screen clock set from the hour and minute you enter." category: - name: "Archived Media" slug: "archived-media" taxonomy: "category" url: "http://localhost/category/archived-media/" post_tag: - name: "Downloadable" slug: "downloadable" taxonomy: "post_tag" url: "http://localhost/tag/downloadable/" - name: "TS 2068" slug: "ts2068" taxonomy: "post_tag" url: "http://localhost/tag/ts2068/" model: - name: "Timex/Sinclair 2068" slug: "ts-2068" taxonomy: "model" url: "http://localhost/model/ts-2068/" indiv: - name: "Leslie Weber" slug: "leslie-weber" taxonomy: "indiv" url: "http://localhost/indiv/leslie-weber/" - name: "Roger Valentine" slug: "roger-valentine" taxonomy: "indiv" url: "http://localhost/indiv/roger-valentine/" genre: - name: "Calendar" slug: "calendar" taxonomy: "genre" url: "http://localhost/type/calendar/" media_contents: - id: 72439 title: "SINCUS Exchange Tape 104" type: "computer_media" url: "http://localhost/computer_media/sincus-exchange-tape-104/" media_type: "Program" programmers: - name: "Leslie Weber" slug: "leslie-weber" taxonomy: "indiv" url: "http://localhost/indiv/leslie-weber/" - name: "Roger Valentine" slug: "roger-valentine" taxonomy: "indiv" url: "http://localhost/indiv/roger-valentine/" download_url: "https://archive.org/download/timex-sinclair-software-archive/Calendar%20and%20Clock%20%28198x%29%28Weber%2C%20Leslie%3B%20Valentine%2C%20Roger%29%28TS2068%29%28US%29%28Program%29.zip" tsrun_member: "Calendar and Clock (198x)(Weber, Leslie; Valentine, Roger)(TS2068)(US)(Program)/Calendar and Clock (198x)(Weber, Leslie; Valentine, Roger)(TS2068)(US)(Program).tap" mediadate: "198x" images: - url: "http://localhost/wp-content/uploads/2026/10/calclock-2.png" article_media: - id: 47325 title: "Calendar Month" type: "article" url: "http://localhost/article/calendar-month/" related_content: - id: 20956 title: "The Timex Sinclair 2068: what can you do with it?" type: "book" url: "http://localhost/book/the-timex-sinclair-2068-what-can-you-do-with-it/" media_type_tags: "Calendar" license: false --- # Calendar and Clock Shows a calendar for any month from 1700 to 1999. You enter the month number and the year, and it prints the month name, the year and the days laid out under SUN to SAT, allowing for leap years. Press 1 for another month or 2 to set the clock: after you type the hour and minute, a white panel shows the running time in hours, minutes and seconds above the calendar. From the clock, 1 returns to the calendar and 2 resets the time. A REM credits the calendar routine to Leslie Weber in the *Basic Computer Newsletter*, Vol. I No. 2, and the clock routine to Roger Valentine’s book *The T/S 2068*. ## Program Analysis ### Calendar Lines 20–140 fill `m()` with the month lengths. The day of the week comes from a count of days since 1800: `365*y+INT (y/4)` plus a constant, plus the lengths of the earlier months, less one in January and February of a leap year, taken modulo 7 in line 310. Subroutines at 500 and 600 are meant to use a different constant for earlier centuries (see Potential Issues). The grid is printed with `TAB col*w+2`, four columns per day. ### Clock Lines 1000–1190 convert the time entered to sixtieths of a second and POKE it into the three-byte frame counter `FRAMES` at 23672–23674. The display loop reads the counter back, divides by 60 and splits it into hours, minutes and seconds, adding leading zeros by string slicing into `t$`. Because the counter is advanced by the TS2068’s 60 Hz interrupt, the clock keeps running while the loop waits for keys. ## Notable Techniques - The leap-year test `y/4=INT (y/4) AND NOT y/100=INT (y/100) OR y/400=INT (y/400)` applies the full Gregorian rule. - The clock needs no timing loop; it simply reads the system frame counter. ## Potential Issues - The subroutines at 500 and 600 work out a day count for years before 1900, but line 250 then subtracts 1800 again and recalculates the count, discarding theirs. Checked against a modern calendar, the months from 1801 to 1999 come out right, while every month from 1700 to 1800 starts on the wrong weekday, despite the “From 1700” heading. - The hour wraps from 12 to 1 only when it reaches 13; there is no AM/PM, and the prompt allows minutes up to 60. - Month and year are not checked; a month outside 1–12 stops with a subscript error. This program came from an Oliger (JLO SAFE) disk and was converted to load from tape. Only the slash in its `SAVE /` had to be removed. It was tested in ZEsarUX. ## Source Code ``` 1 REM calendar routine by Leslie Weber, Basic Computer Newsletter, Vol. I No.2 5 BORDER 2: PAPER 2: INK 7: CLS 6 PRINT : PRINT TAB 7;"Any Calendar Month" 7 PRINT TAB 7;"From 1700 to 1999" 9 PRINT : PRINT 10 LET col=4 20 DIM m(12) 30 LET m(1)=31 40 LET m(2)=28 50 LET m(3)=31 60 LET m(4)=30 70 LET m(5)=31 80 LET m(6)=30 90 LET m(7)=31 100 LET m(8)=31 110 LET m(9)=30 120 LET m(10)=31 130 LET m(11)=30 140 LET m(12)=31 150 INPUT "Number of month? (1-12) ";n 180 INPUT "Year ? (e.g. 1984) ";y 200 PRINT AT 9,22;y 210 LET l=0 220 IF y/4=INT (y/4) AND NOT y/100=INT (y/100) OR y/400=INT (y/400) THEN LET l=1 230 LET dm=m(n) 240 IF n=2 AND l THEN LET dm=29 243 IF y<1900 AND y>1800 THEN GO SUB 500 244 IF y<1800 THEN GO SUB 600 250 LET y=y-1800 260 LET d=365*y+INT (y/4)+2 270 FOR i=1 TO n-1 280 LET d=d+m(i) 290 NEXT i 300 IF n<3 AND l THEN LET d=d-1 310 LET w=d-7*INT (d/7) 320 LET cur=1 325 PRINT 327 GO SUB 700 330 PRINT : PRINT TAB 2;"SUN MON TUE WED THU FRI SAT": PRINT 340 FOR i=0 TO 5 350 FOR j=3 TO 9 360 PRINT TAB col*w+2;cur; 370 IF cur=dm THEN GO TO 450 380 LET cur=cur+1 390 IF w=6 THEN GO TO 420 400 LET w=w+1 410 NEXT j 420 LET w=0 430 PRINT 440 NEXT i 453 PRINT AT 19,0;" TO SEE ANOTHER MONTH PRESS 1 ***** TO SET CLOCK PRESS 2 *****" 455 IF INKEY$="1" THEN GO TO 2 458 IF INKEY$="2" THEN GO TO 1000 460 GO TO 455 465 RUN 500 LET y=y-1800 505 LET d=365*y+INT (y/4)+3 510 RETURN 600 LET y=y-1800 605 LET d=365*y+INT (y/4)+4 620 RETURN 700 IF n=1 THEN PRINT AT 9,4;"January" 702 IF n=2 THEN PRINT AT 9,4;"February" 704 IF n=3 THEN PRINT AT 9,4;"March" 706 IF n=4 THEN PRINT AT 9,4;"April" 708 IF n=5 THEN PRINT AT 9,4;"May" 710 IF n=6 THEN PRINT AT 9,4;"June" 712 IF n=7 THEN PRINT AT 9,4;"July" 714 IF n=8 THEN PRINT AT 9,4;"August" 716 IF n=9 THEN PRINT AT 9,4;"September" 718 IF n=10 THEN PRINT AT 9,4;"October" 720 IF n=11 THEN PRINT AT 9,4;"November" 722 IF n=12 THEN PRINT AT 9,4;"December" 750 RETURN 1000 REM clock routine from 'The T/S 2068' by R. Valentine 1005 BORDER 1: PAPER 1: INK 0 1010 PRINT AT 5,11; PAPER 7;" ";AT 6,11;" ";AT 7,11;" " 1020 DIM t$(8): LET t$(3)=":": LET t$(6)=":" 1030 INPUT "Hour? (1-12) ";h 1040 INPUT "Minute? (0-60) ";m 1050 LET a=(h*3600+m*60)*60 1060 LET b=INT (a/65536): POKE 23674,b 1070 LET c=a-b*65536 1080 LET a=INT (c/256): POKE 23673,a 1090 LET b=c-a*256: POKE 23672,b 1100 LET t=INT ((65536*PEEK 23674+256*PEEK 23673+PEEK 23672)/60) 1110 LET h=INT (t/3600) 1120 LET b=t-h*3600 1130 LET m=INT (b/60) 1140 LET s=b-m*60: IF h=13 THEN LET h=1 1150 LET t$( TO 2)=STR$ h: IF LEN STR$ h=1 THEN LET t$( TO 2)="0"+STR$ h 1160 LET t$(4 TO 5)=STR$ m: IF LEN STR$ m=1 THEN LET t$(4 TO 5)="0"+STR$ m 1170 LET t$(7 TO )=STR$ s: IF LEN STR$ s=1 THEN LET t$(7 TO )="0"+STR$ s 1180 PRINT AT 6,12; PAPER 7;t$ 1184 IF INKEY$="1" THEN GO TO 2 1186 IF INKEY$="2" THEN GO TO 1000 1190 GO TO 1100 1200 STOP 9999 SAVE "calclock" LINE 1: BEEP 1,32 ```