eyc@houxk.UUCP (E.CHEN) (06/04/85)
Here is the C function for getting date and time.
I've gotten from BBS (public domain software).
Hope that this would be a help to you.
Ed. Chen
AT&T IS
##########################################################################
/* Time and Date support for the C86 compiler. Wes Smith */
/* Passed a pointer to a structured described below, fills in the structure
with date and time information from DOS. */
getdati(ptr)
struct datetime
{ char year[5],
month[3],
day[3],
hour[3],
minute[3],
second[3],
msec[3];
} *ptr;
{
struct regval {int ax, bx, cx, dx, si, di, ds, es;};
struct regval srv, rrv;
srv.ax = 0x2A00;
sysint(0x21, &srv, &rrv); /* get date */
itoa(rrv.cx, ptr->year); /* cx = year 9999 */
itoa((rrv.dx>>8), ptr->month); /* dh = month 99 */
itoa(((rrv.dx<<8)>>8), ptr->day); /* dh = month 99 */
srv.ax = 0x2C00;
sysint(0x21, &srv, &rrv); /* get time */
itoa((rrv.cx>>8), ptr->hour); /* ch = hour 99 */
itoa(((rrv.cx<<8)>>8), ptr->minute); /* cl = minutes 99 */
itoa((rrv.dx>>8), ptr->second); /* dh = seconds 99 */
itoa(((rrv.dx<<8)>>8), ptr->msec); /* dl = 1/100 seconds .99 */
}