Re: Calendar Info Needed
- Posted by "M. Schut" <m.schut at TWI.TUDELFT.NL> Jun 18, 1999
- 518 views
>I've a question for you: Does anybody know how the calendar in a PC, say >windows >9x/NT works? I mean, how does the computer know the date/day? I know they >use the >battery to "remember". But where does the info stored, and in what format? Computers (using DOS or Windows) store the date in at least 2 (different) different places. 1. The RTC 2. DOS-timer-tick You can get the current time with in least 3 different ways: 1. Read the RTC (!!! DON'T DO THIS, IT IS BAD PROGRAMMING !!!) 2. Ask the BIOS (Interrupt) 3. Ask the operating system (DOS: Interrupt, Windows: API-call) OK, some history: In the early XT-computers there was NO RTC. So each time DOS-started the current time and date were asked (entered by the user) and stored by DOS, which did update them once and a while. Soon there come additional 'clockcards' to overcome this problem and they could set DOS to the right time and date by itself. (Maybe you remember that little program TIMER.COM about 10 years ago?) When IBM came with the next generation PC's, the AT, they thought the 'clockcard' was very handy and they added it to the PC. They used a Motorola MC416818 which has the capability to keep track of the time and the date and update it when needed [just the last two digits of the date could be updated: the Y2K-problem] and could hold some more bytes in memory as well. As an interface to the user they made the RTC-date and time accessible by BIOS-interrupts (int 1Ah), thus allowing themself to CHANGE the RTC-layout. (And they did: the PS/2 had another layout) The above tells you exactly why it is a bad-programming habit to read the RTC-directly: The RTC-layout may change. Another problem is that the date may be stored in binary format as well as in BCD-format. [ The Y2K-problem started here: The RTC does only store the decades. IBM did offer a 'century-byte' but the Motorola isn't able to update it, without human / BIOS / OS intervention; This reflected in the BIOS which does just add 1900 to these last 2 digits, and the Y2K-problem was completed ] So it is best to use the BIOS-interrupts or the DOS-interrupts or the Windows API. The best overall may be just the date-function build in Euphoria as suggested elsewhere. Just to keep it clear to everyone: The BIOS is the ONLY 'program' that may write direct in the RTC. Sincerely, Martin Schut