2000-02-18 03:39:52 +08:00
|
|
|
/*
|
|
|
|
* asctime_r.c
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <time.h>
|
|
|
|
|
|
|
|
char *
|
2017-12-04 11:43:30 +08:00
|
|
|
asctime_r (const struct tm *__restrict tim_p,
|
2013-11-25 21:46:23 +08:00
|
|
|
char *__restrict result)
|
2000-02-18 03:39:52 +08:00
|
|
|
{
|
2017-12-04 10:25:16 +08:00
|
|
|
static const char day_name[7][3] = {
|
2000-02-18 03:39:52 +08:00
|
|
|
"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
|
|
|
|
};
|
2017-12-04 10:25:16 +08:00
|
|
|
static const char mon_name[12][3] = {
|
2000-02-18 03:39:52 +08:00
|
|
|
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
|
|
|
|
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
|
|
|
|
};
|
|
|
|
|
2011-06-14 22:31:59 +08:00
|
|
|
siprintf (result, "%.3s %.3s%3d %.2d:%.2d:%.2d %d\n",
|
|
|
|
day_name[tim_p->tm_wday],
|
|
|
|
mon_name[tim_p->tm_mon],
|
|
|
|
tim_p->tm_mday, tim_p->tm_hour, tim_p->tm_min,
|
|
|
|
tim_p->tm_sec, 1900 + tim_p->tm_year);
|
2000-02-18 03:39:52 +08:00
|
|
|
return result;
|
|
|
|
}
|