Annotation of prex-old/usr/lib/libc/time/asctime_r.c, Revision 1.1.1.1
1.1 nbrk 1: /*
2: ** This file is in the public domain, so clarified as of
3: ** 1996-06-05 by Arthur David Olson (arthur_david_olson@nih.gov).
4: */
5:
6: #include <sys/time.h>
7: #include <stdio.h>
8: #include <time.h>
9:
10: /*
11: ** A la ISO/IEC 9945-1, ANSI/IEEE Std 1003.1, Second Edition, 1996-07-12.
12: */
13:
14: char *
15: asctime_r(timeptr, buf)
16: register const struct tm * timeptr;
17: char * buf;
18: {
19: static const char wday_name[][3] = {
20: "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
21: };
22: static const char mon_name[][3] = {
23: "Jan", "Feb", "Mar", "Apr", "May", "Jun",
24: "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
25: };
26: const char *wn;
27: const char *mn;
28:
29: wn = wday_name[timeptr->tm_wday];
30: mn = mon_name[timeptr->tm_mon];
31: /*
32: ** The X3J11-suggested format is
33: ** "%.3s %.3s%3d %02.2d:%02.2d:%02.2d %d\n"
34: ** Since the .2 in 02.2d is ignored, we drop it.
35: */
36: (void)sprintf(buf,
37: "%.3s %.3s%3d %02d:%02d:%02d %d\n",
38: wn, mn,
39: timeptr->tm_mday, timeptr->tm_hour,
40: timeptr->tm_min, timeptr->tm_sec,
41: 1900 + timeptr->tm_year);
42: return buf;
43: }
CVSweb