REM Astronomical Clock REM by James Marshall October 11, 1995 REM Based on Eric Bergman-Terrell's (Pocket-Sized Software) Windows program, REM with some additional little improvements for astronomers. ;) REM A five-time clock: LMT (12/24), UT, LST, GST, plus . . . REM JD(Geocentric) and hour angle (user is prompted for a RA if this option REM is chosen). And it has a starry background, too. :) DEF FNtrunc (x) FNtrunc = INT(ABS((x))) * SGN((x)) END DEF REM Print instructions CLS PRINT "ASTRONOMICAL CLOCK by James Marshall" PRINT "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" PRINT PRINT "This program will allow you to view the current time in five different formats:" PRINT "local mean time (12 hour and 24 hour formats), universal time, local sidereal" PRINT "time, and Greenwich sidereal time. It also continually updates the current" PRINT "geocentric Julian Date and you can have the clock display the hour angle for" PRINT "any object, if you know its right ascension. Note that *positive* hour angles" PRINT "mean the object is *west* of the meridian (and negative = east). Also, the" PRINT "starry background randomly changes when you pick a new time format. :)" PRINT PRINT "In order for the program to work properly, you need to edit the file" PRINT "'astclock.dat' which must be in the same directory as the executable, and put" PRINT "the following two values in the file, one on each line:" PRINT " your conversion *from* UT *to* local time" PRINT " your longitude in decimal degrees (- for west)" PRINT PRINT "If the file is not prepared, please break from the program now and edit it to" PRINT "put it in the proper format. If you have received this program from the" PRINT "author, the astclock.dat file is set for his work place, Villanova University," PRINT "Villanova, Pennsylvania, USA." PRINT PRINT "" DO LOOP WHILE INKEY$ = "" OPEN "astclock.dat" FOR INPUT AS #1 INPUT #1, conv INPUT #1, longitude# CLOSE 1 REM Set up an on-screen menu CLS PRINT " Astronomical Clock Menu " PRINT "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" PRINT " F1 --- Local Mean Time, 12 hour " PRINT " F2 --- Local Mean Time, 24 hour " PRINT " F3 --- Universal Time (UT) " PRINT " F4 --- Local Sidereal Time " PRINT " F5 --- Greenwich Sidereal Time " PRINT " F6 --- Local Hour Angle (LHA) " PRINT " F10 -- Quit " LOCATE 3, 49 PRINT "ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»" LOCATE 4, 49 PRINT "º º" LOCATE 5, 47 PRINT "ÉÍÊÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÊÍ»" LOCATE 6, 47 PRINT "º JD º" LOCATE 7, 47 PRINT "ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ" ON KEY(1) GOSUB label1: KEY(1) ON ON KEY(2) GOSUB label2: KEY(2) ON ON KEY(3) GOSUB label3: KEY(3) ON ON KEY(4) GOSUB label4: KEY(4) ON ON KEY(5) GOSUB label5: KEY(5) ON ON KEY(6) GOSUB label6: KEY(6) ON ON KEY(10) GOSUB label10: KEY(10) ON GOTO label2 label1: LOCATE 4, 50 PRINT " " LOCATE 8, 51 PRINT " " GOSUB stars loop1: t$ = TIME$ h$ = LEFT$(t$, 2) h = VAL(h$) m$ = MID$(t$, 4, 2) s$ = RIGHT$(t$, 2) IF h > 12 THEN h = h - 12 h$ = STR$(h) ampm$ = " PM" ELSE ampm$ = " AM" END IF LOCATE 4, 50 PRINT " " + h$ + ":" + m$ + ":" + s$ + ampm$ GOSUB JD KEY(1) ON: GOTO loop1 label2: LOCATE 4, 50 PRINT " " LOCATE 8, 51 PRINT " " GOSUB stars loop2: t$ = TIME$ LOCATE 4, 52 PRINT TIME$ + " LMT" GOSUB JD KEY(2) ON: GOTO loop2: label3: LOCATE 4, 50 PRINT " " LOCATE 8, 51 PRINT " " GOSUB stars loop3: t$ = TIME$ GOSUB UT LOCATE 4, 51 IF h < 10 THEN PRINT " " + h$ + ":" + m$ + ":" + s$ + " UT" ELSE PRINT h$ + ":" + m$ + ":" + s$ + " UT" END IF GOSUB JD KEY(3) ON: GOTO loop3 label4: LOCATE 4, 50 PRINT " " LOCATE 8, 51 PRINT " " GOSUB stars loop4: t$ = TIME$ GOSUB UT GOSUB Sidereal tim# = last# lsth = INT(tim#) lsth$ = RTRIM$(LTRIM$(STR$(lsth))) IF lsth < 10 THEN lsth$ = " " + lsth$ tim# = (tim# - lsth) * 60 lstm = INT(tim#) lstm$ = RTRIM$(LTRIM$(STR$(lstm))) IF lstm < 10 THEN lstm$ = "0" + lstm$ tim# = (tim# - lstm) * 60 lsts = INT(tim#) lsts$ = RTRIM$(LTRIM$(STR$(lsts))) IF lsts < 10 THEN lsts$ = "0" + lsts$ LOCATE 4, 52 PRINT lsth$ + ":" + lstm$ + ":" + lsts$ + " LST" GOSUB JD KEY(4) ON: GOTO loop4 label5: LOCATE 4, 50 PRINT " " LOCATE 8, 51 PRINT " " GOSUB stars loop5: t$ = TIME$ GOSUB UT GOSUB Sidereal tim# = gast# gsth = INT(tim#) gsth$ = RTRIM$(LTRIM$(STR$(gsth))) IF gsth < 10 THEN gsth$ = " " + gsth$ tim# = (tim# - gsth) * 60 gstm = INT(tim#) gstm$ = RTRIM$(LTRIM$(STR$(gstm))) IF gstm < 10 THEN gstm$ = "0" + gstm$ tim# = (tim# - gstm) * 60 gsts = INT(tim#) gsts$ = RTRIM$(LTRIM$(STR$(gsts))) IF gsts < 10 THEN gsts$ = "0" + gsts$ LOCATE 4, 52 PRINT gsth$ + ":" + gstm$ + ":" + gsts$ + " GST" GOSUB JD KEY(5) ON: GOTO loop5 label6: LOCATE 4, 50 PRINT " " GOSUB stars LOCATE 4, 53 PRINT "PAUSED..." LOCATE 11, 1 INPUT "Input the RA of the object (hh:mm:ss): ", ra$ LOCATE 11, 1 PRINT " " rah$ = LEFT$(ra$, 2) rah = VAL(rah$) ram$ = MID$(ra$, 4, 2) ram = VAL(ram$) ras$ = RIGHT$(ra$, 2) ras = VAL(ras$) ra# = rah + (ram / 60) + (ras / 3600) LOCATE 8, 51 PRINT "RA = "; rah$; ":"; ram$; ":"; ras$ loop6: t$ = TIME$ GOSUB UT GOSUB Sidereal tim# = last# IF ra# > 12 AND tim# < 12 THEN tim# = tim# + 24 IF ra# < 12 AND tim# > 12 THEN tim# = tim# - 24 ha# = tim# - ra# hah = INT(ha#) hah$ = RTRIM$(LTRIM$(STR$(hah))) IF hah < 10 AND hah >= 0 THEN hah$ = " " + hah$ IF hah < 0 THEN hah$ = " " + hah$ ha# = (ha# - hah) * 60 ham = INT(ha#) ham$ = RTRIM$(LTRIM$(STR$(ham))) IF ham < 10 THEN ham$ = "0" + ham$ ha# = (ha# - ham) * 60 has = INT(ha#) has$ = RTRIM$(LTRIM$(STR$(has))) IF has < 10 THEN has$ = "0" + has$ LOCATE 4, 51 PRINT hah$ + ":" + ham$ + ":" + has$ + " LHA" GOSUB JD KEY(6) ON: GOTO loop6 label10: FOR i = 10 TO 24 LOCATE i, 1 PRINT " "; NEXT i LOCATE 11, 1 PRINT "Thank you for using the Astronomical Clock! :)" LOCATE 13, 1 END JD: GOSUB UT term1# = 367# * year term2# = FNtrunc((mon + 9) / 12#) term3# = FNtrunc((7 * (year + term2)) / 4#) term4# = FNtrunc((275 * mon) / 9#) + day + 1721013.5# + UT# / 24 term5# = -.5# * SGN(100 * year + mon - 190002.5#) + .5# JD# = term1# - term3# + term4# + term5# LOCATE 6, 52 PRINT USING " #######.#####"; JD# RETURN UT: GOSUB DayOfYear h$ = LEFT$(t$, 2) h = VAL(h$) m$ = MID$(t$, 4, 2) m = VAL(m$) s$ = RIGHT$(t$, 2) s = VAL(s$) h = h - conv IF h < 0 THEN GOSUB TimeTooLow IF h >= 24 THEN GOSUB TimeTooHigh h$ = STR$(h) UT# = h + (m / 60) + (s / 3600) RETURN Sidereal: gmst# = (6.6265313# + .0657098242# * N + 1.00273791# * UT#) omega# = (318.5111# - .0529538# * (N + UT# / 24#)) E# = (-.00029# * SIN(omega# * 3.14159265359# / 180#)) gast# = (gmst# + E#) last# = (gast# + longitude# / 15#) IF (gast# >= 24) THEN gast# = gast# - 24 IF (gast# <= 0) THEN gast# = gast# + 24 IF (last# >= 24) THEN last# = last# - 24 IF (last# <= 0) THEN last# = last# + 24 RETURN TimeTooHigh: h = h - 24: REM change time to proper range day = day + 1: REM change day to proper range IF (((mon = 1) OR (mon = 3) OR (mon = 5) OR (mon = 7) OR (mon = 8) OR (mon = 10) OR (mon = 12)) AND (day > 31)) THEN day = 1 mon = mon + 1 END IF IF (((mon = 4) OR (mon = 6) OR (mon = 9) OR (mon = 11)) AND (day > 30)) THEN day = 1 mon = mon + 1 END IF IF ((mon = 2) AND (day > 28)) THEN day = 1 mon = mon + 1 END IF IF (month > 12) THEN mon = 1 year = year + 1 END IF IF ((INT(year / 4) = (year / 4)) AND (year <> 2000)) THEN IF ((mon = 3) AND (day = 1)) THEN mon = 2 day = 29 END IF END IF RETURN TimeTooLow: h = h + 24: REM change time to proper range day = day - 1: REM change day to proper range IF (((mon = 2) OR (mon = 4) OR (mon = 6) OR (mon = 8) OR (mon = 9) OR (mon = 11) OR (mon = 1)) AND (day < 1)) THEN day = 31 mon = mon - 1 END IF IF (((mon = 5) OR (mon = 7) OR (mon = 10) OR (mon = 12)) AND (day < 1)) THEN day = 30 mon = mon - 1 END IF IF ((mon = 3) AND (day < 1)) THEN day = 28 mon = mon - 1 END IF IF (month < 1) THEN mon = 12 year = year - 1 END IF IF ((INT(year / 4) = (year / 4)) AND (year <> 2000)) THEN IF ((mon = 2) AND (day = 28)) THEN day = 29 END IF RETURN DayOfYear: d$ = DATE$ mon$ = LEFT$(d$, 2) mon = VAL(mon$) day$ = MID$(d$, 4, 2) day = VAL(day$) year$ = RIGHT$(d$, 4) year = VAL(year$) term1 = FNtrunc((275 * mon) / 9) term2 = FNtrunc((mon + 9) / 12) term3 = 1 + FNtrunc((year - 4 * FNtrunc(year / 4) + 2) / 3) term4 = day - 30 N = term1 - term2 * term3 + term4 RETURN stars: RANDOMIZE (TIMER) FOR i = 12 TO 24 LOCATE i, 1 PRINT " "; NEXT i FOR i = 1 TO 60 x = INT((24 - 12 + 1) * RND + 12) y = INT((80 - 1 + 1) * RND + 1) LOCATE x, y PRINT "*"; NEXT i RETURN