2 * asctime - print a date
4 /* $Id: asctime.c,v 1.4 1994/06/24 11:57:57 ceriel Exp $ */
10 #define DATE_STR "??? ??? ?? ??:??:?? ????\n"
13 two_digits(register char *pb, int i, int nospace)
15 *pb = (i / 10) % 10 + '0';
16 if (!nospace && *pb == '0') *pb = ' ';
18 *pb++ = (i % 10) + '0';
23 four_digits(register char *pb, int i)
26 *pb++ = (i / 1000) + '0';
28 *pb++ = (i / 100) + '0';
30 *pb++ = (i / 10) + '0';
31 *pb++ = (i % 10) + '0';
35 char *asctime(const struct tm *timeptr)
38 register char *pb = buf;
39 register const char *ps;
43 ps = _days[timeptr->tm_wday];
45 while(--n >= 0) *pb++ = *ps++;
47 ps = _months[timeptr->tm_mon];
49 while(--n >= 0) *pb++ = *ps++;
53 two_digits(two_digits(pb, timeptr->tm_mday, 0)
54 , timeptr->tm_hour, 1)
56 , timeptr->tm_sec, 1);
58 four_digits(pb, timeptr->tm_year + 1900);