[comp.os.msdos.misc] Midnight Bug

jy@wasp.eng.ufl.edu (Jim Yousse) (05/14/91)

Does anyone know about the Midnight Bug in DOS, where the clock does not
register a date change when passing midnight?  We have a user here who
leaves her machine on continuously, and every now and then it will lose
a day.  We're pretty sure this is the midnight bug in action.  We've heard
of fixes for this, but don't know where to get one.  Any suggestions?
Thanks.

kevin@nodecg.ncc.telecomwa.oz.au (Kevin Spencer) (05/16/91)

In article <1991May13.180754.25187@eng.ufl.edu> jy@wasp.eng.ufl.edu (Jim Yousse) writes:
>Does anyone know about the Midnight Bug in DOS, where the clock does not
>register a date change when passing midnight?  We have a user here who
>leaves her machine on continuously, and every now and then it will lose
>a day.  We're pretty sure this is the midnight bug in action.  We've heard
>of fixes for this, but don't know where to get one.  Any suggestions?
>Thanks.

This is due to DOS only setting a flag instead of incrementing a counter when
midnight is passed. ie, as the clock ticks past midnight, DOS sets a flag
indicating that it's a new day. This flag is reset, and the date incremented,
when the BIOS Get-Date function(s) are called. What this boils down to is
that, if your computer is on over an entire midnight-midnight period without
the clock being read, you will lose a day. I haven't developed a fix for this
yet, although I will need to soon as I intend to start leaving my machine on
24-hours in a few months. However, a TSR should do the trick. A simple one
which does a BIOS Get-Date call whenever the time equals a certain value (ie,
once/day) would work. This may or may not display the time/date on the screen
(depends on what you want). There are probably some PD programs around which
do just that. However, you need to make sure that they use the BIOS, rather
than direct memory reads.

PS - I'm not sure that it's a BIOD Get-Date call. It may be Get-Time instead.
	 I don't have the manuals handy.

-- 
-----------------------------------///-----------------------------------------
Kevin Spencer (09) 420 8173       /// Insert profound gem of wisdom here...
kevin@ncc.telecomwa.oz.au     \\\///
-------------------------------\XX/--------------------------------------------

leonard@qiclab.scn.rain.com (Leonard Erickson) (05/17/91)

jy@wasp.eng.ufl.edu (Jim Yousse) writes:

>Does anyone know about the Midnight Bug in DOS, where the clock does not
>register a date change when passing midnight?  We have a user here who
>leaves her machine on continuously, and every now and then it will lose
>a day.  We're pretty sure this is the midnight bug in action.  We've heard
>of fixes for this, but don't know where to get one.  Any suggestions?

Well, unless you have an *old* version of DOs, it works like this:

At midnight, the TimerCount (in the BIOS work area at 0040:????) is
reset to 0. And another memory location in that area is *set* to 1.
(Not incremented, *set*).

The next time anything asks DOS for the date or time, DOS sees the "flag"
is set, clears it, and increments the date by one. 

So you only lose a day if nothing asks DOS for the Date or time for
*two* days. 

The solution is to install *something* that keeps checking the time,
say a menu program with a clock display in the corner. Or even a TSR
that displays the time on screen somewhere.

Last I heard, Microsoft had no intention of fixing this.
-- 
Leonard Erickson			leonard@qiclab.uucp
personal:	CIS: [70465,203]	70465.203@compuserve.com
business:	CIS: [76376,1107]	76376.1107@compuserve.com