From f95a4a932476be2ba99e2fd081e8d2bc6ea12813 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Fri, 15 Dec 2017 09:38:53 -0500 Subject: Import newlib and create makefile --- newlib/libc/time/asctime_r.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 newlib/libc/time/asctime_r.c (limited to 'newlib/libc/time/asctime_r.c') diff --git a/newlib/libc/time/asctime_r.c b/newlib/libc/time/asctime_r.c new file mode 100644 index 0000000..ff70ea4 --- /dev/null +++ b/newlib/libc/time/asctime_r.c @@ -0,0 +1,27 @@ +/* + * asctime_r.c + */ + +#include +#include + +char * +_DEFUN (asctime_r, (tim_p, result), + _CONST struct tm *tim_p _AND + char *result) +{ + static _CONST char day_name[7][3] = { + "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" + }; + static _CONST char mon_name[12][3] = { + "Jan", "Feb", "Mar", "Apr", "May", "Jun", + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" + }; + + sprintf (result, "%.3s %.3s %.2d %.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); + return result; +} -- cgit v1.2.3