26

In most versions of DOS, when they are started from a medium that lacks an AUTOEXEC.BAT file, the very first thing COMMAND.COM does is ask the user to confirm the current date and time:

Starting PC DOS...

Current date is Thu 10-01-2020 Enter new date (mm-dd-yy): Current time is 9:42:41.44a Enter new time:

PC DOS Version 7.10 (C)Copyright International Business Machines Corp 1981-2002.

A:>

This behaviour persisted until very late versions of DOS. Microsoft removed it only as late as in MS-DOS 7.0 (i.e. Windows 95), while IBM has never removed it from PC DOS (transcript above comes from PC DOS 7.10, downloaded from IBM themselves); DR-DOS likewise kept it until its very last versions. MS-DOS 1.0 will even require the user to enter a date unless AUTOEXEC.BAT is present, and wouldn’t proceed to a command prompt otherwise; later versions relaxed this, allowing the user to press Enter to confirm the currently set date. Even FreeCOM replicates this behaviour (as of 0.84-pre2).

This behaviour doesn’t seem necessary. Standard PC hardware includes a real-time clock powered by a battery; this allows current date and time to be maintained across power cycles, when the rest of the hardware is otherwise not functioning. It should be safe for the OS to assume that the current date and time are already set correctly upon booting.

Why is this behaviour present, why was it tied to the presence of AUTOEXEC.BAT and why did it persist for so long?

user3840170
  • 23,072
  • 4
  • 91
  • 150
  • 1
    How certain are you that command.com did this automatically? I seem to remember Compaq DOS 3.1 requiring explicit date and time commands to be placed in autoexec.bat to get this prompt on startup. – mschaef Oct 01 '20 at 14:15
  • 8
    Pretty damn certain — I mean, it’s right there in the source code, and I tested some later versions too. Remember that even an empty AUTOEXEC.BAT file will suppress the prompt. Then though, there is also a possibility that Compaq DOS contained a modified version of COMMAND.COM. – user3840170 Oct 01 '20 at 18:12
  • 2
    It's also documented in tens if not hundreds of books about DOS, including Microsoft's own MS-DOS 3.3 User's Guide and User's Reference, which I just pulled off the shelf and checked; both under the date command and in the section on autoexec.bat. Google Books tells us that it's also in the 1984 COMPAQ User's Handbook. – JdeBP Oct 02 '20 at 06:31
  • Thanks, it was the presence of the autoexec.bat part of the statement that I missed. Not sure I ever booted without a startup script, so never saw the automatic display. – mschaef Oct 02 '20 at 20:01
  • 2
    From a different point of view, would there be a better event than boot to ask? – Andrew Morton Oct 04 '20 at 19:26
  • From the computer's point of view, whole geological eons have passed since you switched it off. – A. I. Breveleri Feb 23 '21 at 20:47

3 Answers3

64

Because it used to be necessary.

While a battery-powered real-time clock is standard today, this wasn’t always the case. The very first IBM 5150 did not include an RTC chip; the system clock was maintained by the PIT interrupt running on the CPU, which in particular meant that disabling interrupts halted the system clock. When the computer was turned off, there was no hardware inside to maintain the clock. A number of third-party extension boards were available to overcome this problem; only with the PC/AT did an RTC chip become a built-in feature.

The above part is uncontroversial. The rest of this answer is considerably more speculative.

Skipping the date and time prompt when AUTOEXEC.BAT is present allowed the user to establish the current date and time at boot-up in some other way than prompting for manual input (which was probably exploited by drivers for the above-mentioned devices). In fact, this seems to have been the original purpose of AUTOEXEC.BAT in the first place: the /D switch used to skip processing AUTOEXEC.BAT was added primarily to suppress the date and time prompt, as implied by a comment in source code and overtly stated in internal documentation.

While an RTC eventually became a standard PC feature, Microsoft (and apparently Digital Research which developed DR DOS) probably wanted to maintain support for hardware which lacked it (including non-PC-compatible hardware), so instead of requiring the user to input the date and time, DOS started to allow the user to confirm the current setting. By the time computers without an RTC became vanishingly rare, this behaviour became a non-issue, as most computers would have an AUTOEXEC.BAT file present anyway, if only to set the PATH environment variable. DOS vendors therefore focused their attention on other concerns.

Also, even a battery-powered RTC would occasionally need to be manually adjusted for Daylight Saving Time and to correct clock skew (thanks @Ron Maupin for pointing the latter out), as the RTC on DOS computers was, infamously, usually set to local time and tended to drift a lot (as it does to this day, but now at least we have NTP to take care of it). Prompting the user to confirm the current time could serve as a mechanism ensuring the clock is set more-or-less accurately and that the DST adjustment is not overlooked. (This seems a weak justification now, especially given it’s a speculative one, and seems to contradict the AUTOEXEC.BAT connection somewhat. Myself, I would expect this behaviour to instead train the user to press Enter twice each time the system boots up without paying attention to the prompt. But maybe it is only in hindsight that we understand effects like banner blindness.)

With Windows 95, booting without an AUTOEXEC.BAT file became a much more common (and in fact, preferred) configuration: Andrew Schulman’s Unauthorized Windows 95 makes note that this was much emphasised in the press at the time. In a clean installation, only the non-English versions would create an AUTOEXEC.BAT file, where it would invoke MODE and KEYB commands setting up DOS locale settings. Only then did Microsoft decide that asking for the date and time on boot-up is superfluous and removed it, whether AUTOEXEC.BAT was present or not. (Even the DST justification wouldn’t have made sense any more, as DST adjustments are instead handled by the graphical interface.) Other DOS vendors apparently never felt the need to address it.

user3840170
  • 23,072
  • 4
  • 91
  • 150
  • Isn't the battery only needed for when machine is plugged out of the power? Why didn't they power RTC from the mains, even when PC was off? – Matej Drobnič Oct 02 '20 at 04:20
  • 19
    @MatejDrobnič Because the power switch controls mains in a standard AT supply, there was no mains available to have a standby supply, so a battery is necessary to keep time. – Justme Oct 02 '20 at 04:35
  • Rex Conn's 4DOS documented the /D switch, and it remains to this day, albeit with a modified meaning. https://jpsoft.com/help/cmdlineopts.htm – JdeBP Oct 02 '20 at 05:38
  • 5
    My understanding is that the original IBM PC didn't simply lack a battery; it lacked the real-time clock. When the system was powered up, the CPU would keep the time, so the RTC was only needed when the system was powered down. It would be pointless to supply a clock that was only necessary with power off, yet not include a battery. Think of the RTC as a watch that you could buy for your computer, which it would read upon startup. – Gabe Oct 02 '20 at 05:44
  • 1
    Comments are not for extended discussion; this conversation has been moved to chat. – wizzwizz4 Oct 03 '20 at 13:40
  • @Gabe I'm sure you are correct. Clock used to run behind if you ran software that disabled interrupts. This was also an issue with early clock-cards that required a command to sync the RTC clock with the software clock (e.g. didn't have a TSR to maintain sync). Usually clock got only set RTC by a command in autoexec and several hours later the clock was "early". Had a typist going ballistic once. She discovered the files she saved from WordStar by the end of the day had timestamps that where about 30 minutes "early". Her boss looked at the timestamps and accused her of going home too early. – Tonny Oct 04 '20 at 12:44
  • Unless software is messing with timer tick interrupts, the PC's clock should be fairly accurate since it's based on a crystal. Every 12 ticks of a 14,381,818Hz crystal, the PC clocks a counter/timer chip, and every 65,536 pulses yields an interrupt which increments a counter. If that counter hits IIRC 1,573,042 (which is just short of 65536 times 24) it wraps around, but a flag is set telling MS-DOS to advance the date at its next opportunity. Why the BIOS and MS-DOS didn't e.g. keep time by e.g. adding 0xE0F9794 to a 64-bit counter (so that the upper 32 bits would... – supercat Oct 04 '20 at 17:03
  • ...increment once per second) I'm not sure, since a branchless 64-bit add would be simpler than having to handle the weird wraparound cases, and would simplify display of DOS times (simply load AX with bits 16-31 and multiply by 100 to compute the hundredths fraction in DX). – supercat Oct 04 '20 at 17:06
11

It was necessary, because the early hardware did not contain a Real Time Clock (RTC) chip. The first IBM PC model to have an RTC chip as a standard feature and supported by BIOS was the IBM PC/AT, and earlier models could be retrofitted with an add-on RTC ISA card. So the models before AT cannot possibly know the current time automatically after powering the computer on or pushing the reset button, so it made sense to assume that by default, when there is no AUTOEXEC.BAT, the user wants to set the system time when DOS loads, and if there was an AUTOEXEC.BAT, it would prompt the user for date and time at a suitable point if necessary, or run an utility that reads the current time from the RTC addon card and sets the system time accordingly.

Justme
  • 31,506
  • 1
  • 73
  • 145
  • For even more, look at the February 1988 issue of PC Magazine for the getclock.scr program listing and at http://minuszerodegrees.net/rtc/rtc.htm . – JdeBP Oct 02 '20 at 06:41
1

Standard PC hardware includes a real-time clock powered by a battery

I guess this is a valid assumption since IBM PC AT.

Older PCs (PC, PCjr, XT) has no RTC by default (due to Wikipedia).

Martin Maly
  • 5,535
  • 18
  • 45