1 /*
2 Copyright (c) 1994 Cygnus Support.
3 All rights reserved.
4 
5 Redistribution and use in source and binary forms are permitted
6 provided that the above copyright notice and this paragraph are
7 duplicated in all such forms and that any documentation,
8 and/or other materials related to such
9 distribution and use acknowledge that the software was developed
10 at Cygnus Support, Inc.  Cygnus Support, Inc. may not be used to
11 endorse or promote products derived from this software without
12 specific prior written permission.
13 THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
14 IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
15 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
16  */
17 /*
18  * asctime_r.c
19  */
20 
21 #include <stdio.h>
22 #include <time.h>
23 
24 char *
asctime_r(const struct tm * __restrict tim_p,char * __restrict result)25 asctime_r (const struct tm *__restrict tim_p,
26 	char *__restrict result)
27 {
28   static const char day_name[7][3] = {
29 	"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
30   };
31   static const char mon_name[12][3] = {
32 	"Jan", "Feb", "Mar", "Apr", "May", "Jun",
33 	"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
34   };
35 
36   sprintf (result, "%.3s %.3s%3d %.2d:%.2d:%.2d %d\n",
37 	    day_name[tim_p->tm_wday],
38 	    mon_name[tim_p->tm_mon],
39 	    tim_p->tm_mday, tim_p->tm_hour, tim_p->tm_min,
40 	    tim_p->tm_sec, 1900 + tim_p->tm_year);
41   return result;
42 }
43