2022-04-27 12:39:39 +00:00
|
|
|
#include "libc/calls/weirdtypes.h"
|
2022-08-14 00:20:50 +00:00
|
|
|
#include "libc/time/struct/tm.h"
|
2020-06-15 14:18:57 +00:00
|
|
|
#include "libc/time/time.h"
|
|
|
|
|
2023-10-03 02:25:19 +00:00
|
|
|
/**
|
|
|
|
* Represents time as string.
|
|
|
|
* @threadunsafe
|
|
|
|
*/
|
2022-04-27 12:39:39 +00:00
|
|
|
char *ctime(const time_t *timep) {
|
|
|
|
/*
|
|
|
|
** 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))
|
|
|
|
*/
|
|
|
|
struct tm *tmp = localtime(timep);
|
|
|
|
return tmp ? asctime(tmp) : NULL;
|
|
|
|
}
|