Files
semi-libc/src/time/ctime_r.c
T
Rich Felker 64f855874c handle errors from localtime_r in ctime_r
POSIX requires ctime_r return a null pointer on failure, which can
occur if the input time_t value is not representable in broken down
form.

based on patch by Alexander Monakov.
2017-06-20 20:31:35 -04:00

8 lines
150 B
C

#include <time.h>
char *ctime_r(const time_t *t, char *buf)
{
struct tm tm, *tm_p = localtime_r(t, &tm);
return tm_p ? asctime_r(tm_p, buf) : 0;
}