Date: Thu, 14 Apr 1994 17:17:26 -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: ctime again Hi, I have had several people request that if I hear of a solution to the ctime ``bug'' to let them know what it is. Well, although not a solution, the code below does return the current time and date in the proper ctime format. 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; } --John