Time and space define our place in the Universe. On Earth, most of us know where we are, at least in relation to a local frame of reference, which is adequate enough to navigate the immediate area. We only have to look at a clock or a watch to know what the current time is, and to work out how long we have to get somewhere else.
We take all this for granted, without thinking about all the historical effort that has gone into setting up this time system, and mapping the Earth's surface. But what about life on another planet? How about a climb up Olympus Mons or a trip to explore the depths of Hellas Planitia. Not possible you say? Well maybe not yet in person, but there are two rovers currently exploring the surface of Mars, and several dozen people on Earth controlling these vehicles who are living in two different Martian time zones. And if you wish to follow closely the exploits of these rovers, you might also be interested in space and time on Mars, for the two are closely related.
The BASIC code presented here is for a Mars clock, which can be set to different points on the Martian surface. It is based on algorithms carefully devised by Michael Allison of the Goddard Institute for Space Studies. Now, Robert Schmunk has written a program in Java called Mars24 that may be downloaded from the Goddard web site, and that is also based on these algorithms. His program includes not only a clock but also a map, with several projections and shades of day and night. While this is very nice program, it does have a very large overhead, including a Java engine that must be downloaded as well.
The program presented here has no graphics, but computes a large amount of information with just 83 lines of code, which compiles to an executable file of less than 45KB, and that will run on any old PC that you might wish to turn into a dedicated Mars Clock. On the other hand, it will also run under the QBASIC interpreter in a small window in the background of your Pentium 4. And this program has source code that can help you to understand the principles involved, and that you can modify to suit your own tastes.
Under the QBASIC interpreter or another editor, the code (list 1) must be entered and saved in a file (named say MARSCLOK.BAS). The program also requires a data file from which configuration variables and data is read. An example data file is shown in list 2. The data file must be named MARSCLOK.DAT. The first line of this file contains the name of the time zone to which your PC time is set, and also the numerical time zone (examples of time zones for several countries are given in list 3). The second and following lines of the data file contain the name, latitude and longitude (decimal degrees) of up to ten different locations on Mars.
The program can be run under DOS or under any of the Microsoft Windows operating systems, either full screen or as a small window. In the latter case the size of the window can be changed by changing the font size. I have found a font size of 7x12 optimum, but this will depend on your screen resolution.
To change from one location to another, simply press any numeric key from 0 to 9.
MARSCLOK source code [MARSCLOK.BAS]
100 DIM loc$(10), lat(10), lon(10) 'MARS CLOCK [MARSCLOK.BAS] 110 DEFDBL A-Z: pi = 3.141592653#: dr = pi / 180: i = 0 120 OPEN "marsclok.dat" FOR INPUT AS #1: INPUT #1, tz$, tz 130 DO WHILE NOT EOF(1): INPUT #1, loc$(i), lat(i), lon(i) 140 i = i + 1: LOOP: CLOSE #1: MD = 24.65979: il = 0 150 CLS : COLOR 14, 0: PRINT " MARS CLOCK": esc$ = CHR$(27) 160 COLOR 10, 0: LOCATE 3, 9: PRINT "EARTH TIME" 170 dt$ = DATE$: tM$ = TIME$: ut = TIMER / 86400 - tz / 24 180 PRINT : PRINT , dt$, tM$; " "; tz$; " = UT + "; tz 200 yr = VAL(RIGHT$(dt$, 4)): mn = VAL(LEFT$(dt$, 2)) 210 dy = VAL(MID$(dt$, 4, 2)): dyt = dy + ut: srs = 90.25 * dr 220 PRINT : COLOR 12, 0: PRINT " MARS PARAMETERS" 230 mlat = lat(il): mlon = lon(il): mloc$ = loc$(il) 240 COLOR 13, 0: PRINT : PRINT , "LOCATION - "; mloc$; " "; 250 PRINT USING "Lat ###.# Lon ####.#"; mlat; mlon: PRINT 300 N = INT(yr + FIX((mn - 9) / 7)) 310 N = -INT(3 * (INT(N / 100) + 1) / 4) 320 N = N - INT(7 * (INT((mn + 9) / 12) + yr) / 4) 330 N = N - 730516.5 + dyt + 367 * yr + INT(275 * mn / 9) 400 tM = N - 4.5: MSD = 44795.99976# + tM * 24 / MD + mlon / 360! 420 MSH = (MSD - INT(MSD)) * 24 430 MSM = (MSH - INT(MSH)) * 60: MSHh = INT(MSH) 440 Myr = INT(MSD / 668.5921) 450 Mday = INT(MSD - INT(Myr * 668.5921)) 500 M = (19.41 + .5240212# * N) * dr: sM = SIN(M): cM = COS(M) 510 Afms = Afms - INT(Afms / 360) * 360: s2M = SIN(2 * M) 520 Afms = 270.39 + .5240384# * N: s3M = SIN(3 * M): s4M = SIN(4 * M) 540 Ls = Afms + (10.691 + 3.7E-07 * N) * sM + .623 * s2M 550 Ls = Ls + .05 * s3M + .005 * s4M: Lr = Ls * dr 560 RA = Ls - 2.86 * SIN(2 * Lr) + .071 * SIN(4 * Lr) - .002 * SIN(6 * Lr) 570 EoT = (Afms - RA) / 15: MTST = MSH + EoT: Ls = Ls - INT(Ls / 360) * 360 580 MTSTh = INT(MTST): MTSTm = (MTST - MTSTh) * 60 590 MTSTh = MTSTh - INT(MTSTh / 24) * 24 600 sDec = .4256 * SIN(Lr): c2M = COS(2 * M) 610 Dec = ATN(sDec / SQR(1 - sDec * sDec)) / dr + .25 * SIN(Lr) 620 rM = 1.00436 - .09309 * cM - .00436 * c2M 630 rM = rM - .00031 * COS(3 * M): rM = 1.5236 * rM 640 LM = Ls + 85.06 + .000029 * N: LM = LM - INT(LM / 360) * 360 650 Le = 100.472 + .9856474 * N: Le = Le - INT(Le / 360) * 360 660 G = (357.528 + .9856003 * N) * dr 670 LA = Le + 1.915 * SIN(G) + .02 * SIN(2 * G) 680 rE = 1.00014 - .01671 * COS(G) - .00014 * COS(2 * G) 690 rME = SQR(rE * rE + rM * rM - 2 * rE * rM * COS((LM - LA) * dr)) 700 ha = 15 * (MSH - 12 + EoT) 710 ha = ha - INT(ha / 360) * 360: IF ha > 180 THEN ha = ha - 360 715 sl = SIN(mlat * dr): cl = COS(mlat * dr): sD = SIN(Dec * dr) 720 SE = sl * sD: cD = COS(Dec * dr) 730 SE = SE + cl * cD * COS(ha * dr): hah = ha / 15 740 IF SE = 1 THEN el = 90: az = 0: GOTO 800 750 el = ATN(SE / SQR(1 - SE * SE)) / dr: az = 90 760 cA = (sD - sl * SE) / cl / SQR(1 - SE * SE): IF cA = 0 THEN 790 770 az = ATN(SQR(ABS(1 - cA * cA)) / cA) / dr 780 IF az < 0 THEN az = 180 + az 790 IF ha > 0 THEN az = 360 - az 800 CMP = 12 - EoT: sha = (COS(srs) - sl * sD) / cl / cD 810 IF ABS(sha) > 1 THEN sr = 0: ss = 0: GOTO 850 820 sha = ATN(SQR(1 - sha * sha) / sha) / dr / 15 830 IF sha < 0 THEN sha = sha + 12 840 sr = CMP - sha: ss = CMP + sha 850 srh = INT(sr): srm = (sr - srh) * 60: srh = (srh + 24) MOD 24 860 ssh = INT(ss): ssm = (ss - ssh) * 60: srh = (srh + 24) MOD 24 870 dl = ss - sr: IF dl < 0 THEN dl = dl + 24 880 IF dl = 0 AND el > 0 THEN dl = 24 890 tME = rME * 499 / 60: rMm = rM * 150: rMEm = rME * 150 900 COLOR 14, 0: PRINT , "Mars Mean Local Time "; 905 PRINT USING "##:##"; MSHh; MSM: PRINT , "Mars Date Year "; 910 PRINT USING "### ME Day ### [MSD=######.###]"; Myr; Mday; MSD 915 PRINT : COLOR 12, 0: PRINT , "Mars True Solar Time "; 920 PRINT USING "##:## [EoT = ###.# minutes]"; MTSTh; MTSTm; EoT * 60 925 PRINT , ; : PRINT USING "Solar Longitude Ls = ###.## deg"; Ls 930 PRINT , ; : PRINT USING "Solar Dec = ###.# deg "; Dec; 935 PRINT USING "HA = ###.# hours"; hah: PRINT , ; 940 PRINT USING "Solar Elevation = ### deg Azimuth = ### deg"; el; az 945 COLOR 9, 0: PRINT : PRINT , ; 950 PRINT USING "Distance to Sun = #.## AU ###.# million km"; rM; rMm 955 PRINT , ; : PRINT USING "Distance to Earth = #.## AU "; rME; 960 PRINT USING "###.# million km"; rMEm: COLOR 7, 0: PRINT : PRINT , ; 965 PRINT USING "Communications Delay ##.# minutes (E-M)"; tME 970 PRINT : COLOR 14, 0: PRINT , ; : PRINT "Sunrise "; 975 PRINT USING "##:## Sunset ##:##"; srh; srm; ssh; ssm; 980 PRINT USING " Hours of Daylight ##.#"; dl; 990 a$ = INKEY$: IF a$ <> "" THEN il = VAL(a$) 999 IF a$ <> esc$ THEN 160
MARSCLOK Data File [MARSCLOK.DAT]
WAST,8 "Prime Meridian",0,0 "Airy Crater ",-5.2,0 "Mars 2 ",-45,58 "Viking 1 ",22.48,-47.95 "Viking 2 ",47.70,134.28 "Pathfinder ",19.28,-33.55 "Spirit ",-14.74,175.48 "Opportunity ",-1.98,-5.94 "Beagle 2 ",11.6,90.5 "Prime Meridian",0,0
|UT or GMT (England or Scientific)||0|
|EST (Eastern Standard Time -USA)||-5|
|CST (Central Standard Time - USA)||-6|
|MST (Mountain Standard Time - USA)||-7|
|PST (Pacific Standard Time - USA)||-8|
|AEST Australian Eastern Standard Time||+10|
|CAST Central Australian Standard Time||+9.5|
|WAST West Australian Standard Time||+8|
THE MARSCLOK SCREEN
Following the heading, the date and time to which your computer is set are displayed. The difference between this zonal time and UT is also indicated. This is simply the time zone value read from the data file. From the terrestrial date/time, all the other Martian dates and times are computed.
Under the heading "Mars Parameters", the location name, latitude and longitude of the place of interest are printed. Note that latitude and longitude are positive to the north and east respectively (see conventions later on).
Because the orbit of Mars is quite eccentric, true solar time can be quite different from time reckoned on a mean Sun (ie as if Mars moved in a truly circular orbit about the Sun). It is always mean solar time that is used on Earth, and this may be different from true solar time by up to 16 minutes. On Mars, the difference may be up to 51 minutes. This difference is called the Equation of Time (EoT).
On Earth, to avoid having an infinity of times around the world, we also use zonal times, in which your zonal time is reckoned to the nearest hourly multiple from Universal Time (that is, the Earth is divided into 24 hourly zones, which each cover 15 degrees of longitude). Thus your zonal time may be different from true solar time due to two factors: (1) your longitudinal displacement from the zonal longitude, and (2) the equation of time (EoT) difference.
In Marsclock, we have not used zonal times. We have instead calculated the mean and true solar times right at the longitude of the place of interest. The Local Mean Solar Time is displayed first, and this is followed by the local Martian date. There is as yet no accepted division of the Martian year into months, and the program displays the Martian year and the day within the year. The designation ME stand for "Mars Era" which we will explain shortly. Mars days have been termed "sols", and the quantity labelled MSD is the Mars Sol Date (in sols) calculated from the start of the Mars Era.
Note that the time is in Martian hours, and the date is in Martian days - we need to forget about Earth time when we are on Mars.
The following block of data displays the Local True Solar Time (which is equal to the Mean Time plus the EoT). The next parameter is the solar longitude. This is important to tell what Martian season we are in. A longitude of 0 degrees corresponds to the Martian northern hemisphere vernal equinox. Longitudes of 90, 180 and 270 are then the northern hemisphere summer solstice, autumnal equinox, and winter solstice respectively.
The next two lines show solar parameters such as the solar declination, the local solar hour angle (negative to the east in the morning), the solar elevation (negative angles mean the Sun is below the horizon) and the solar azimuth (measured from 0 to 360 degrees starting from the north and moving clockwise through east).
The following two lines show the distance from Mars to the Sun and to the Earth respectively, this distance being given both in Astronomical Units and kilometres. The communications delay is the time it takes light, or a radio wave to travel from Mars to the Earth (one way), and is shown in decimal minutes.
Lastly, Marsclok shows the sunrise and sunset times (specified in mean local time), together with the total hours of daylight you will experience at the given location on Mars (dust clouds permitting).
CONSTANTS AND CONVENTIONS
Because time is intrinsically related to space, it is necessary to have a well defined positional reference system for Mars. The equator is defined by the rotational axis of the planet, but we need a reference from which to measure longitude. On Earth, the prime meridian is the one that passes through (or used to) the Royal Greenwich Observatory in England. On Mars, the prime meridian is taken to pass through the center of the small crater Airy-0 inside the larger crater Airy, named after the historical Astronomer Royal at Greenwich.
For some time Martian studies (areography) used a system in which longitude was measured as positive to the west. The IAU several years ago approved a new coordinate system in which east is taken as the positive direction. This is the convention adopted in Marsclok, and is more consistent with most terrestrial usage, both in longitude and time zones. (Note that this differs from the Mars24 program).
The calculation of a Martian date is problematical. One Martian year = 668.5921 Martian days or sols, and the 0.59 fraction is rather awkward. It is not a matter of having a leap year every 4th year. To overcome this problem involves a repeating sequence of short and long years over a 76 Martian year period. A Martian short year is 668 sols, while a Martian long year is 669 sols. The sequence necessary to keep the calendar accurately synchronized with the seasons is given below.
|S L S L S L L S L S L L S L S L L S L S L L|
|S L S L S L L S L S L L S L S L L S L S L L S L S L L|
|S L S L S L L S L S L L S L S L L S L S L L S L S L L|
|Sequence of Martian short and long years [22 + 27 + 27 = 76 years]|
|This sequence repeats without change for almost a thousand years|