EasyManua.ls Logo

Atari ST series - Page 50

Atari ST series
420 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
CHAPTER 3
0000 1111 1001 0111 0110 0111 0010 0011
and grouping the bits as required:
0000111 1100 10111 01100 111001 00011
7 12 23 12 49 3
1987 December 23d 12:49:06 p.m.
This gives a year of 7 (1987), a month of 12 (December), a
day of 23, an hour of 12 (noon), a minute value of 49, and a
seconds value of 3. Thus, the date shown is December 23,
1987, and the time is 12:49:06 p.m. (The seconds value is the
quotient of seconds divided by two.)
XGETTIME.C (Program 3-1) shows how to use Gettime()
function to find the date and time.
Program 3-1. XGETTIME.C
/**********************************************/
/* */
/* XGETTIME.C Demonstrates reading */
/* the IKBD clock/calendar and */
/* interpreting the results. */
/* */
/ft*********************************************/
#include <osbind.h> /* For macro definitions */
main()
(
unsigned long datetime, xbiosQ;
unsigned int date, time;
unsigned int second, minute, hour;
unsigned int day, month, year;
datetime = Gettime(); /* get time and date longword */
time = (int)datetime; /* time is low word */
date = (int) (datetime»16) ; /* date is high word */
second = (time & OxlF) *2; /* secs/2 in 1st 5 bits */
minute = (time»5) & 0x3F; /* minutes in next 6 */
hour = time » 11; /* hours in last 5 */
day = date & OxlF; /* day in 1st 5 bits */
month = (date » 5) & OxF; /* month in next 4 */
year = (date » 9) + 80; /* year-1980 in last 6 */
printf ("The date is %d/%d/%d and the time is %d:%d:%d \n",
month,day,year,hour,minute,second);
)
/********** end of XGETTIME.C ********/
Note that though this function returns the date and time
in the same format as the comparable GEMDOS functions, it
does not use the same clock. Gettime() uses the hardware
clock found in the IKBD device (or the Real-Time-Clock on
the Mega STs), while the GEMDOS functions use a software
clock maintained by GEMDOS. On 520 and 1040 STs, it is
42

Related product manuals