ProDOS 8: How To Set, Save, and Retrieve Date/Time Data

I have a third-party clock device connected to the game port of an Apple IIe. I also have a BASIC routine that returns the time and date in a variable.

The problem is that the routine does not store the date and time in a place where other ProDOS programs (that is, AppleWorks) can access them. Is there a standard memory location and format for storing the time and date so that all other applications can retrieve it? I'm assuming that most ProDOS programs use the "GetTime" call. Is it possible to preload the memory locations that "GetTime" references?
There is a standard memory location and format designated by ProDOS for the Date/Time data.

ProDOS has a built-in clock driver that queries a clock/calendar card for the date and time. After the routine stores that information in the ProDOS Global Page ($BF90-$BF93), either ProDOS or your own application programs can use it.

The locations reserved by ProDOS for the Date/Time are $BF90-$Bf93.

The format looks like this:
Date:49041 ($BF91) 49040 ($BF90)
7 6 5 4 3 2 1 7 6 5 4 3 2 1
| Year | Month | Day |
Time:49043 ($BF93) 49042 ($BF92)
7 6 5 4 3 2 1 7 6 5 4 3 2 1
| Hour | | Minute |

The ProDOS clock driver expects the clock card to send an ASCII string to the GETLN input buffer ($200). This string must have the following format (including the commas):

mo,da,dt,hr,mn

where:
mo is the month (01 Jan...12 Dec)
da is the day of the week (00 Sun..06 Sat)
dt is the date (00 through 31)
hr is the hour (00 through 23)
mn is the minute (00 through 59)

For example, 07,04,14,22,46 represents Thursday, July 14, 10:46 PM. The year is looked up in a table in the clock driver.

To support clock cards that do not follow the ProDOS protocol defined above, you can locate your code in a number of places. The cleanest solution is to replace the ProDOS routines with your own, if they fit. If you look at $BF07, $BF08, you will find the location to put your code. There is room for 125 bytes.

There is more information about this subject in the ProDOS 8 Technical Reference Manual, Chapter 6, "Adding Routines to ProDOS", beginning on page 104.

The disadvantage is that once the date/time is loaded by your routine, there is no way to update it without returning to your own program to reset the memory locations with the new date/time. This would get pretty cumbersome if done often.
Published Date: Feb 18, 2012