Atari ST series Technical Reference Manual page 50

Hide thumbs Also See for ST series:
Table of Contents

Advertisement

0000 1111 1001 0111 0110 0111 0010 0011
and grouping the bits as required:
0000111
1100
7
12
1987
December
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 —
/*
the IKBD clock/calendar and
/*
interpreting the results.
/*
/ft*********************************************/
#include <osbind.h>
main()
(
unsigned long datetime, x b i o s Q ;
unsigned int date, time;
unsigned int second, minute, hour;
unsigned int day, month, year;
datetime = Gettime();
time = (int)datetime;
date = (int) (datetime»16) ;
second = (time & OxlF) *2;
minute = (time » 5 )
hour = time »
day = date & OxlF;
month = (date »
year = (date »
printf ("The date is %d/%d/%d and the time is %d:%d:%d \ n",
m o n t h ,d a y ,y e a r ,h o u r ,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
CHAPTER 3
10111
01100
23
12
23d
Demonstrates reading
/* For macro definitions
/* get time and date longword */
/* time is low word */
/* date is high word */
/* secs/2
& 0x3F;
minutes in next 6 */
/*
11;
/* hours in last 5 */
/ *
day in 1st 5 bits */
5) & OxF;
/* month in next 4 */
9) + 80;
/* year-1980 in last 6 */
111001
00011
49
3
12:49:06 p.m.
*/
*/
*/
*/
*/
*/
in 1st 5 bits */

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents