Date: Wed, 31 Aug 1994 05:46:07 -0400 From: davis AT amy DOT tch DOT harvard DOT edu ("John E. Davis") To: djgpp AT sun DOT soe DOT clarkson DOT edu Subject: Re: New time routines Forgive me for being naive. I am probably missing something very fundamental but I simply want the time routines to return the same value that the time and date commands give at the DOS prompt--- independent of environment variable settings and zoneinfo files. No other DOS compiler needs it and no how hard you try, DOS is not Unix and will never be POSIX compliant. The way I see it, the only ``absolute'' time is NOW and every other time value is ``relative'', that is difference of two time values which, I think, is independent of the timezone. That leaves NOW to deal with and the way I see it, NOW is what DOS says it is. Thus: char *djgpp_current_time (void) { union REGS rg; unsigned int year; unsigned char month, day, weekday, hour, minute, sec; char days[] = "SunMonTueWedThuFriSat"; char months[] = "JanFebMarAprMayJunJulAugSepOctNovDec"; static char the_date[26]; rg.h.ah = 0x2A; int86(0x21, &rg, &rg); year = rg.x.cx & 0xFFFF; month = 3 * (rg.h.dh - 1); day = rg.h.dl; weekday = 3 * rg.h.al; rg.h.ah = 0x2C; int86(0x21, &rg, &rg); hour = rg.h.ch; minute = rg.h.cl; sec = rg.h.dh; /* we want this form: Thu Apr 14 15:43:39 1994\n */ sprintf(the_date, "%.3s %.3s%3d %02d:%02d:%02d %d\n", days + weekday, months + month, day, hour, minute, sec, year); return the_date; }