
     PCs AND THE YEAR 2000

     Much ado has been made about a forthcoming problem with PCs when the 
     date changes from December 31, 1999, to January 1, 2000.  Many people 
     are alarmed to discover that when they boot up their computers in the 
     year 2000 the computer will instead show 1980.  To repeat this simple 
     test on your computer, try changing the date and time on your computer 
     to 12-31-1999 and 11:59pm.  Wait a minute or two and then reboot your 
     computer.  Computers I have checked boot up with January 4, 1980, 
     though others have reported other dates such as January 1 or April 1.

     While I have seen allegations that this is a problem with DOS and/or 
     with the computer's BIOS, I believe the problem is in the design of 
     the realtime (RT) clock.  If the computer is left running during the 
     rollover to year 2000, DOS will correctly show 2000, but the date 
     error will show up the next time the computer is booted up.  If the 
     incorrect date is corrected to the year 2000, subsequent reboots are 
     handled correctly and the date error does not occur again.  This, in 
     my opinion, indicates a problem isolated to the RT clock's rollover 
     from 1999 to 2000.  DOS has no problem reading or writing files using 
     the year 2000.  Even when a directory listing shows, for example, a 
     filedate of "01-01-00", DOS knows it is really 2000 and that it is a 
     later date than "12-31-99".


     HOW THE COMPUTER KEEPS TIME

     Your PC actually runs two timekeepers.  One is a simple clock chip 
     and is part of the computer hardware.  This is often located on the 
     motherboard, and may be combined or integrated inside another chip.  
     This is a simple clock much like your digital watch and runs 
     continuously, even when the computer is turned off, and is powered 
     by the CMOS battery.  This clock may be referred to as the realtime 
     (RT) clock, CMOS clock, or hardware clock.
     
     The second timekeeper is the system clock, which DOS creates in your 
     computer's RAM.  DOS uses the system clock for most of its functions, 
     such as writing the date and time files are saved.  The problem with 
     the system clock is that it ceases to exist when the computer is 
     turned off.  In normal operation DOS queries the RT clock when it 
     boots up in order to intialize the system clock, but thereafter the 
     system clock keeps time independently from the RT clock.  

     The RT clock contains registers for the various components of the 
     date and time, as well as the logic circuitry to increment the 
     registers, convert 0:60 to 1:00, etc.  Two of these registers are 
     Century (2 digits) and Year (2 digits).  Experimentation indicates 
     the logic to increment the Century register is missing in some clock 
     chips, so when the Year register rolls over from "99" to "00" it 
     does not increment the Century register.  Thus, the combination 
     "1999" rolls over to "1900" instead of "2000".

     DOS does not seem to have a problem rolling over from 1999 to 2000, 
     but remember the RT clock is running independently and so DOS will 
     not show the error until the next time it reads the RT clock, which 
     is usually the next time it boots up.  So where does the 1980 date 
     come from?  Understand that DOS only recognizes dates from 1-1-1980 
     to 12-31-2099, so if the RT clock gives DOS a date of 1900, the 
     result will be unpredictable (though DOS generally seems to respond 
     with something in 1980).  Note the rest of the RT clock's registers 
     continue to increment normally, so it has no problem advancing from 
     January 1 to January 2, etc.; it is only the Century that does not 
     automatically advance.  If the RT clock is not reset, it may continue 
     to increment normally (e.g., from 1-1-1900 to 1-2-1900) but DOS will 
     continue to behave unpredictably at each reboot as long as the date 
     is out of the range DOS understands.  If the clock is reset to 2000, 
     when DOS reboots it will receive a response it can recognize, so there 
     will be no problem thereafter.

     
     TESTING YOUR RT CLOCK

     The utility, 2000TEST.COM, will test your computer's RT clock and 
     report what it rolls over to after 12-31-1999.  It will also test 
     whether or not a Century of 2000 can be set in your RT clock.  To 
     use the utility, simply type "2000TEST" and press the [Enter] key.  
     In operation, the utility:

          1. Reads and saves the current RT clock Date and Time,

          2. Sets the RT clock to 12-31-1999 at 23:59:59,

          3. Waits for the Time to change,

          4. Reads and reports what the Date changed to,

          5. Sets the RT clock to 01-01-2000,

          6. Checks if the RT clock reads back with 01-01-2000,

          7. Restores the original (saved) Date to the RT clock,

          8. Reads the DOS system time, converts it to RT clock 
             format, and sets the RT clock Time.

     In steps 1 and 7 the utility presumes the date does not change while 
     it is executing.  However, the time will change so in step 8 the RT 
     clock is reset from the system clock, not from the Time value saved 
     in step 1 (only the Daylight Savings Flag is recovered from step 1).  
     If the system clock is in synch with the RT clock, this procedure 
     should reset the RT clock to within 1 second of what it started with 
     before the utility was run.


     USING 2000FIX.COM

     So what do you need to do if your computer rolls over from 1999 to 
     1900?  If your RT clock cannot be set to 2000, your computer will 
     indeed be in trouble when the 21st century arrives.  But if it can 
     be set to 2000, all you need to do is reset the date and everything 
     should work fine.  Using the DATE command in DOS will reset both 
     the system clock and the RT clock.

     If you're afraid you might forget to reset the date, you can use 
     the utility 2000FIX.COM.  Simply add 2000FIX to your AUTOEXEC.BAT 
     file and it will check the RT clock's date every time you boot up.  
     The utility does nothing unless it finds a year of 1900 in the RT 
     clock, in which case it resets the year to 2000.  Rather than also 
     fix the system clock, the utility will take the lazy way out and 
     prompt you to reboot to correct your system clock.

     I probably won't bother to use 2000FIX myself, but it's so simple 
     I've included it for anyone who is... well, I'll be nice.


     DISCLAIMER

     Use 2000TEST and 2000FIX at your own risk.  I make no warranties 
     about their suitability for your purpose.  Source code for both 
     utilities is hereby released to the public domain.  Source code 
     is provided in the format of DEBUG scripts so you don't need a 
     commercial compiler to create the program files.  Simply make 
     sure DEBUG.COM (which should have come with your DOS version) is 
     available on the path and create the COM files with the syntax:

          DEBUG < 2000TEST.SCR  or  DEBUG < 2000FIX.SCR

     2000TEST and 2000FIX are not intended for use with early 8088 IBM 
     PCs and XTs.  Those computers did not come with a standard RT clock, 
     so the utilities may return unpredictable results.


     ---------------------------------------------------------------------

     Dan Goodell   (71520.3116@compuserve.com)
     1261 Hookston Road, Concord CA 94518

     April 25, 1996

     ---------------------------------------------------------------------
     
     Addendum:  In the interest of accuracy, it should be noted that 
     further discussion on CompuServe suggests the Century register 
     is not actually part of the RT clock but is carried in a section 
     of the CMOS RAM on most motherboards.  This would help explain 
     why the "circuitry" is missing in the RT clock to increment the 
     Century register when the Year register rolls over from "99" to 
     "00".  The distinction is not overly relevant, especially with 
     many modern motherboards coming with the CMOS RAM, RT clock and 
     embedded battery in a single module.  The key is whether or not 
     the computer is capable of retaining the Century data (whether 
     in CMOS RAM or RT clock) when the computer is turned off.

     -DG  July 28, 1996

     ---------------------------------------------------------------------
     
     Addendum:  PC Magazine, in their October 6, 1998 issue, has
     publicized several utilities for testing the PC RT clock.
     Several cost money.  Frankly, it surprises me that anyone would
     expect you to pay them $30 or more for what is essentially little
     more than a few minutes of programming effort.  But, as I think
     PT Barnum once said, "There's a sucker born every minute."

     Some of the utilities highlighted require you to reboot your
     system.  This is not necessarily safe if you have installed
     programs that look at the system date for expiration cues, and
     when you reboot you are letting the operating system (DOS, Win3.1
     or Win95) restart with a future date that may prematurely expire
     those programs.

     Actually, rebooting should not even be necessary -- we're testing
     the hardware, not the operating system (Microsoft and others are
     doing that).  The widely publicized manual test (as set forth in
     the opening paragraph above) does involve a reboot, but merely as
     an indirect means of finding out what the RT clock rolled over to.
     2000TEST tests the RT clock directly and does not require a reboot.
     The system clock is never changed (remember -- once booted, the
     system clock runs independently of the RT clock) and the operating
     system shouldn't even know the RT clock was temporarily fiddled
     with.  Thus, 2000TEST should be safer than the manual test.

     If your RT clock can keep the year 2000 but rolls over to 1900,
     buying a new bios chip should be unnecessary unless there are
     other enhancements you will also benefit from (for example,
     support for large hard disks if your current bios does not have
     that).  Installing programs that use TSRs to automatically fix
     your date seems a bit radical to me, as well as unnecessarily
     exposing you to the risks of possible conflicts with the OS.
     A large majority of errant hardware will require nothing more
     than resetting the date once we get to 2000 -- a two-second,
     once-in-a-lifetime operation.

     Yet, we should be mindful of letting the OS boot with bad date
     data.  If you do have date-tracking software that looks at the
     system time for expiration cues, an incorrect date may expire
     your program before you get around to resetting the date.  The
     TSR-style solutions presumably will prevent that.

     The TSR approach, though, seems unnecessary.  The 2000FIX utility
     enclosed here is a non-TSR solution.  Leaving 2000FIX in your
     AUTOEXEC.BAT file will fix an incorrect date when it occurs
     (assuming your bios is one that rolls over from 1999 to 1900) and
     prevent your system from booting with a bad date.  The utility
     has been slightly modified from the 1996 original to now force a
     reboot when needed instead of merely recommending it.  That should
     prohibit the OS from booting with a bad date.  2000FIX is not a
     TSR and should not ever conflict with the OS.  If it does not
     need to fix your RT clock it disappears and your system boots up
     without it.

     Much ado has also been made of a possible leapyear problem in 
     the year 2000.  This sounds like alarmist hype to me, but I guess
     it may be remotely possible.  While century years are normally
     not leapyears (the 100-yr rule), 2000 is indeed a leapyear (the
     400-yr rule).  It would take extra programming code for the
     conscientious bios or RT clock designer to support the 100/400-yr
     rules, and it wouldn't even matter until the year 2100.  Thus,
     even the lazy or uninformed programmer would get the leapyear
     right for the year 2000!  Still, some people seem to be worried
     about it, so 2000TEST has been slightly modified to now include
     a leapyear test.

     As previously stated, the user assumes all risk for the use of
     2000TEST and 2000FIX, though they don't do anything undocumented
     or proprietary.  The utilities have been tested with DOS, Win3.1
     and Win95 systems.  2000TEST will even run straight from the
     Win95 "Start | Run" menu.

     With this explanation and the enclosed utilities, the informed
     user should be able to cut through much of the hyperbole about
     Year-2000 problems with PC hardware.

     Software problems, though, are another matter.

     -DG  October 20, 1998

     ---------------------------------------------------------------------
