1. Calendar Info Needed

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?

If you don't know what am I asking for, let me put it this way:
Pick a digital watch with date function, the manufacturer said its calendar
is
"programmed" to year 2030, for example. That means the watch knows exactly
the
day for ANY given date between now and Dec 31, 2030. It knows which year is
a
leap year, date of week, and what's the day for, let's say Tuesday, June 15,
1999.

If you're using a GUI now, there's a date available to you to access
somewhere.
How are these info stored/programmed in a computer? Is it programmed
somewhere
in the ROM?  Is it possible to access it with Euphoria?

new topic     » topic index » view message » categorize

2. Re: Calendar Info Needed

Hmm, good question.

SHORT ANSWER: I don't know for sure.

LONG ANSWER: Well, I'm not sure if it is stored in the ROM or not, that
sounds reasonable to me.  But where ever it is I don't think that the
date/day and all is stored there. I believe that the only thing that the
internal battery has to power is a little counter that counts the number of
seconds since some date in the past (probably Jan 1, 1900).  All the
additional information is probably CALCULATED from that single number at
boot time and stored somewhere in RAM. I'm pretty sure someone here has more
facts about it than I.

Lewis Townsend




Original message:

>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?
>
>If you don't know what am I asking for, let me put it this way:
>Pick a digital watch with date function, the manufacturer said its calendar
>is
>"programmed" to year 2030, for example. That means the watch knows exactly
>the
>day for ANY given date between now and Dec 31, 2030. It knows which year is
>a
>leap year, date of week, and what's the day for, let's say Tuesday, June
>15,
>1999.
>
>If you're using a GUI now, there's a date available to you to access
>somewhere.
>How are these info stored/programmed in a computer? Is it programmed
>somewhere
>in the ROM?  Is it possible to access it with Euphoria?
>


_______________________________________________________________
Get Free Email and Do More On The Web. Visit http://www.msn.com

new topic     » goto parent     » topic index » view message » categorize

3. Re: Calendar Info Needed

On Wed, 16 Jun 1999, Leung, Ying-Kit wrote:

] 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?

The BIOS in your computer holds the date and time, usually in a
proprietary format, BIOS for BIOS. DOS (or whatever other operating system
you use) polls the BIOS for the date and time on startup, so that it can
align itself with the machine.

An example BIOS date could look like this:

Hex: 10 06 07 CF CD 14 63
      |  |  | |  |  |
     16/06/1999  52500 seconds since midnight

     The high bit of the '63' byte represents whether 65536 seconds have
     passed since midnight. If set, 65536 should be added to the total
     seconds count. The lower order bits represent 100ths of a second.

     In this case, the time translates as 14:35:00.99, if I've done my
     sums right :)

IIGC Euphoria gets the date info from DOS/Windows.

If you're after writing a calendar program, I'm sure there's something
available on the Euphoria Contributions pages that'll have an algorithm
for dealing with dates.

FWIW, I never got around to translating my Calendar programs into
Euphoria. There buried somewhere on my hard drive in QBasic.

I might just dust them off and translate them...

HTH,
Carl

--
Carl R White -- Final Year Computer Science at the University of Bradford
E-mail........: cyrek- at -bigfoot.com -- Remove hyphens. Ta :)
URL...........: http://www.bigfoot.com/~cyrek/
Uncrackable...: "19.6A.23.38.52.73.45 25.31.1C 3C.53.44.39.58"

new topic     » goto parent     » topic index » view message » categorize

4. Re: Calendar Info Needed

-----Original Message-----
From:   Leung, Ying-Kit [SMTP:Ying-Kit.Leung at CAN.XEROX.COM]
Sent:   Wednesday, June 16, 1999 2:12 PM
To:     EUPHORIA at LISTSERV.MUOHIO.EDU
Subject:        Calendar Info Needed

>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?


PC's All have a special chip in them which acts like a digital watch, this
chip is called the RTC (Real Time Clock). You can program the current date
and time (like setting your watch), from then on it runs by itself even
when the main power is switched off (powered by the battery you mention).
 The PC can then access this information at any time it wishes.

BTW some PC clock chips can keep track of the current day of the week, but
this IMHO is not a lot of use if you are manipulating dates in the
future/past.

NB. Any thing more than this information and you must program it yourself.

If you want to workout what the day of the week, or if 2000 is a leap year,
then it all need's to be calculated, by your program.  The algorithms for
date&time manipulation are readily available on the Internet. I can dig a
few URL's out if you get stuck.  or even just post some old C & Pascal code
I once wrote.

>If you're using a GUI now, there's a date available to you to access
>somewhere.

No matter if you are using dos or a GUI accessing the RTC will be the same

>How are these info stored/programmed in a computer? Is it programmed
>somewhere
>in the ROM?

The RTC can be accessed  directly through ports 70 and 71 hex

>is it possible to access it with Euphoria?

I guess so smile

new topic     » goto parent     » topic index » view message » categorize

5. Re: Calendar Info Needed

What is the addresses of the BIOS date/time?
Can I use Peek() to get the data?

> -----Original Message-----
> From: Carl R. White [SMTP:C.R.White at SCM.BRAD.AC.UK]
> Sent: Wednesday, June 16, 1999 9:39 AM
> To:   EUPHORIA at LISTSERV.MUOHIO.EDU
> Subject:      Re: Calendar Info Needed
>
> On Wed, 16 Jun 1999, Leung, Ying-Kit wrote:
>
> ] 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?
>
> The BIOS in your computer holds the date and time, usually in a
> proprietary format, BIOS for BIOS. DOS (or whatever other operating system
> you use) polls the BIOS for the date and time on startup, so that it can
> align itself with the machine.
>
> An example BIOS date could look like this:
>
> Hex: 10 06 07 CF CD 14 63
>       |  |  | |  |  |
>      16/06/1999  52500 seconds since midnight
>
>      The high bit of the '63' byte represents whether 65536 seconds have
>      passed since midnight. If set, 65536 should be added to the total
>      seconds count. The lower order bits represent 100ths of a second.
>
>      In this case, the time translates as 14:35:00.99, if I've done my
>      sums right :)
>
> IIGC Euphoria gets the date info from DOS/Windows.
>
> If you're after writing a calendar program, I'm sure there's something
> available on the Euphoria Contributions pages that'll have an algorithm
> for dealing with dates.
>
> FWIW, I never got around to translating my Calendar programs into
> Euphoria. There buried somewhere on my hard drive in QBasic.
>
> I might just dust them off and translate them...
>
> HTH,
> Carl
>
> --
> Carl R White -- Final Year Computer Science at the University of Bradford
> E-mail........: cyrek- at -bigfoot.com -- Remove hyphens. Ta :)
> URL...........: http://www.bigfoot.com/~cyrek/
> Uncrackable...: "19.6A.23.38.52.73.45 25.31.1C 3C.53.44.39.58"

new topic     » goto parent     » topic index » view message » categorize

6. Re: Calendar Info Needed

-----Original Message-----
From:   Leung, Ying-Kit [SMTP:Ying-Kit.Leung at CAN.XEROX.COM]
Sent:   Wednesday, June 16, 1999 3:36 PM
To:     EUPHORIA at LISTSERV.MUOHIO.EDU
Subject:        Re: Calendar Info Needed

>What is the addresses of the BIOS date/time?
The BIOS RTC Services are on INT 1Ah (See Below)

>Can I use Peek() to get the data?
NO!.  (unless Peek can access I/O Mappings?)

The BIOS is ROM so contains nothing that changes like the current time

What I think was ment, is use the BIOS Interrupt service to access the RTC
hardware

FYI
INT 1A - System and Real Time Clock BIOS Services

      INT 1A,0   Read system clock counter
      INT 1A,1   Set system clock counter
      INT 1A,2   Read real time clock time (AT,PS/2)
      INT 1A,3   Set real time clock time (AT,PS/2)
      INT 1A,4   Read real time clock date (AT,PS/2)
      INT 1A,5   Set real time clock date (AT,PS/2)
      INT 1A,6   Set real time clock alarm (AT,PS/2)
      INT 1A,7   Reset real time clock alarm (PS/2)
      INT 1A,8   Set RTC activated power on mode (convertible,PS/2)
      INT 1A,9   Read RTC alarm time and status (convertible,PS/2)
      INT 1A,A   Read system day counter (PS/2)
      INT 1A,B   Set system day counter (PS/2)
      INT 1A,80  Set up sound multiplexer (PCjr only)

      - function is specified in register AH

new topic     » goto parent     » topic index » view message » categorize

7. Re: Calendar Info Needed

DOS GET DATE                             ( SET DOS DATE INT 21 2B )
INT21 FUNCTION 2A                        { USES SAME REGISTERS    )
RETURNS:
AL = DAY
CX = YEAR ( 1980 - 2099 )
DH = MONTH
DL = DAY OF THE WEEK ( 0 = SUNDAY )
----------------------------------------------------------------------------
DOS GET TIME                             ( SET DOS TIME INT 21 2D )
INT21 FUNCTION 2C                        { USES SAME REGISTERS    )
RETURNS:
CH = HR
CL = MIN
DH = SEC
DL = 1/100 SEC
----------------------------------------------------------------------------

BERNIE

new topic     » goto parent     » topic index » view message » categorize

8. Re: Calendar Info Needed

On Wed, 16 Jun 1999, you wrote:
> What is the addresses of the BIOS date/time?
> Can I use Peek() to get the data?
>
If you only want to read the data, why not just use Euphoria's date()
function?

Irv

new topic     » goto parent     » topic index » view message » categorize

9. Re: Calendar Info Needed

>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

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu