PERPETUAL CALENDAR 1900-2100by CHARLES POSTLE
Did you ever want to know how many days old you are? This computerized Julian perpetual calendar tells you exactly how many days ago a specific event happened. You can also see a screen display of any calendar month between March 1900 and February 2100. The BASIC program works on all Atari 8-bit computers of any memory size, with disk or cassette.
The Egyptian astronomer, Sosigenes, suggested to Julius Caesar in the year 46 BC that the calendar currently in use was a little out of step with the natural year. The natural year was actually 365.25 days long instead of 365. The solution, said Sosigenes, was to create a "leap" year every four years. And so it came to pass.
Some time later, it was discovered the 365.25-day year is just about 0.01 days too long. Rather than lose sleep over this, the great thinkers of the day brought our calendar up to date in the year 1900. It was felt that no more corrections would be needed until 2100.
Micro Julius is a computerized perpetual calendar with bells and whistles. It bases its calculations on the 365.25-day Julian Year. Since only dates between March 1,1900 and February 28, 2100 can be figured using this method, there are limits to this program. (Look for an update of Micro Julius in the February, 2100 issue of Antic-ANTIC ED)
Type in Listing 1, JULLAN.BAS, check it with TYPO II and SAVE a copy before you RUN it. Micro Julius will first ask you for a date, in this order: Month, Day, Year. If, for example, you want to enter today's date as May 15, 1986, type: 5,15,1986 [RETURN].
The full date will be printed to the screen as May 15, 1986 THURSDAY After a brief pause, a menu will appear with several options.
First, you may enter another date to find out the difference in days. Want to know how many days old you are? Let's say you were born October 5,1959. Choose selection 1 and press [RETURN]. Type 10,5,1959 [RETURN]. If all is going well, you should discover that you are 9719 days old.
Selection 2 lets you subtract a number of days from the first date you entered. Exactly 250 days from May 15,1986 was Saturday, September 7, 1985. Numerologists may wish to apply their magic numbers to this function.
Going on a 90-day diet? Well, if you start it on May 15, 1986, you can celebrate with a binge on Wednesday August 13. Use Selection 3 to add a number of days to your first date and mark the result on your calendar!
Selection 6 draws a page of the chosen month to the screen-labelling it appropriately and highlighting the given day
In programming, any math done with dates can be greatly simplified by first converting the date to what's known as a "Julian day number". This is the date, chronologically numbered from some known starting point. The conversion in Micro Julius takes place in lines 120 through line 170. This resulting number can now be treated like an integer in math problems.
Once the day number has been mathematically massaged, it can be reconverted back to a date again. Lines 180 through 270 do the reconversion. Note lines 130 through 150 and lines 220 through 270. Since the extra day in a leap year is added to the month of February, these lines distort the calender year to look as though it ends in February. Lines 290-310 figure the day of the week.
Menu Selection 1 allows a second date to be entered. This second date will be converted to a Julian day and the absolute values of the two days subtracted. The result is the number of days between the two dates. Line 650 performs this task.
Menu Selection 2 subtracts a number of days from the date first entered. Line 730 takes care of this, after which the program reconverts the result back to a new date in the subroutine at line 180.
Menu Selection 3 adds a number of days to the date (line 760) and again reconverts the result to a new date (line 180 subroutine again).
Selection 4 starts the program over so you can begin with a new date (line 780). Selection 5 ends the program.
To draw a calendar page (Selection 6), the program first finds out on what day of the week the month starts. This is done in lines 800-830. Then the program finds the Julian day number for the first day of the following month. Subtracting the two day numbers tells the program how many days are in the month in question. This is done in lines 850-890.
Lines 900-950 assign the days of the month to A$ string and make sure any previous assignments are blanked out. Lines 960-980 change the date to be highlighted into inverse video.
The C$ string is the actual calendar that will be printed. Lines 1040-1090 put the day-of-week symbols into the first week. These will be overwritten by any day of the month that falls coincidentally in the same space. Lines 1130-1150 match the days of the month (A$ string) to the calendar (C$ string).
The program is written to display the calendar page to the screen only (Lines 1160-1420). Printer output would be an interesting addition but, since printer graphics vary so widely, I leave this task to the reader.
I've tried to make the program as easy to use as possible. However, I might caution the reader that these calculations should not be used to figure financial interest and payments, because many banking institutions use a 30 day month and a 360 day year to calculate these matters.
Charles Postle is a construction superintendant in the Las Vegas area. He writes much of his own software in BASIC.
Listing 1 JULIAN.BAS Download