amiga-tz/library/time_ctime.c

33 lines
768 B
C

#include "time_header.h"
/**
* @brief
* Section 4.12.3.2 of X3.159-1989 requires that
* The ctime function converts the calendar time pointed to by timer
* to local time in the form of a string. It is equivalent to
* asctime(localtime(timer))
*
*/
char* ctime(const time_t *const timep)
{
struct tm *tmp = localtime(timep);
return tmp ? asctime(tmp) : NULL;
}
char* ctime_r(const time_t *const timep, char *buf)
{
struct tm mytm;
struct tm *tmp = localtime_r(timep, &mytm);
return tmp ? asctime_r(tmp, buf) : NULL;
}
char* ctime_rz(const timezone_t tz, const time_t *const timep, char *buf)
{
struct tm mytm, *rtm;
rtm = localtime_rz(tz, timep, &mytm);
if (rtm == NULL)
return NULL;
return asctime_r(rtm, buf);
}