Fix2010 v1.0a1

by Avi Drissman, drissman@acm.org
http://www.drissman.com/avi/newton/

Requirements

A Newton device with Newton OS 2.0 or greater.

About 5K free on your internal store.

Purpose

Fix2010 allows your Newton's clock to be set past 2010, and allows it to roll over past 2010 without incident.

Installation

Are you crazy?

This is ALPHA-quality software. It has undergone almost no testing. It has not proved itself. It will not become useful for another 12 years. I wouldn't recommend installing it. Period.

Still want to install it? Back up your Newton. Totally. More than once. Do not install this on mission-critical machines. Really.

Ensure that packages are installed on the internal store. Use the Newton Connection Utilities program that came with your Newton device to download the included package.

Use

Use your Newton as usual. Fix2010 should be transparent.

Known Issues

The minute timer of the clock doesn't work after 2010. This is due to some stupidity in its programming; I may patch it in a later version of Fix2010.

Around 2100, things get funky due to the fact that 2100 is not a leap year, yet some pieces of the Newton OS think it is. I may or may not get to fixing this.

The Newton time system is dead after 2920. You probably will be too.

Developer Notes

The main guts of this patch is obviously the patch to Time. Let me explain to you what I'm doing, and you'll understand better.

The real-time clock that runs the Newton runs from 1993 through 2010. This is due to the fact that NewtonScript integers are 30 bits, and signed. 229 seconds after 1993 is 2010--the end of the Seconds world. The time system, however, is based on minutes from 1904. That won't run out until 2920. Then we'll really be screwed.

That means that the clock has a 17-year life. After that, the clock will have to be made to repeat some Seconds values. I've defined a term called a hexade. A hexade is a block of 16 years. Hexade 0 is from 1993 (1/1/93, 12AM) to 2009 (1/1/09, 12AM). Hexade 1 is the 16-year block after 2009, and so on. I suppose we could deal with the negative hexades too, but I really don't care, and I don't think anyone else does either.

The function Time is patched out to read the current hexade (GetUserConfig('hexade)--don't touch that value!), read the RTC, bring the time into the current hexade, and return it. Remember, the RTC thinks we're in hexade 0.

The function TimeInSeconds is not patched out. I felt this was best for compatibility. This means two things: first, the Seconds timebase is no longer 1993; it is the first year of the current hexade. Secondly, you'd better not rely on Seconds values being consistent.

Here is a list of functions, and some notes on how they're changed by the installation of Fix2010. (Not all of them are patched; but some rely on patched routines.)

AddAlarm
The alarm soup is slightly hacked up. Please use only documented functions to do alarms. Please don't screw around with them yourself. Oh, yeah--AddAlarm works fine.
AddAlarmInSeconds
This works, as long as you remember that the Seconds base is the first year of the current hexade, and not necessarily 1993. Or, if you're not sure, just pass in a date frame.
DateFromSeconds
Works fine--just remember the new Seconds timebase.
GetAlarm
Use it--just follow the advice of the Newton Programming Reference manual (14-11): Do not touch the returned frame. The new slot in the frame is a hexade slot, holding the hexade of the alarm. I know that it's not really necessary, since it can be computed from the time and timeInSeconds slots, but I'm lazy.
SetTime
Ah, very important. Pass in any date from 1904 to 2920, with no problem. Or a date frame. See SetTimeInSeconds, below, for more details.
SetTimeInSeconds
Just remember that if you pass in a seconds value, you cannot change the date from this hexade. If you want to do so, you'll need to pass a date frame. This function, as well as SetTime, checks the hexade of the new date. If it is different, then it changes to the new hexade, and walks and adjusts the system alarm soup before setting the RTC.
Time
Returns the current time. Any time from 1904 to 2920.
TimeInSeconds
This is not patched; it returns the value from the RTC. Just keep in mind the Seconds timebase.
TimeInSecondsToTime
Just remember the new Seconds timebase. This, like all the other Seconds functions, uses the new base.
TimeToTimeInSeconds
Once again, keep the new timebase in mind.
TotalSeconds
Works, but just remember the new Seconds timebase. TotalSeconds(0) is not necessarily 1993.

Version History

Version 1.0a1 (28 September 1998)
Initial release for sick, demented alpha-version chasers

Legal stuff

This is going to very much less pretty than anything I've ever written before:

Fix2010 is supplied to you AS-IS. Avi Drissman cannot be held responsible and disclaims any resposibility for any damage caused to any Newton device by Fix2010. That's why you should back up.

Fix2010 is highly experimental. Play with it as you would play with high-voltage power lines--be careful, be alert, don't do anything stupid, let Avi know if something happens, and keep children away.