diff options
| author | Meco Man <[email protected]> | 2021-02-11 02:32:47 +0800 |
|---|---|---|
| committer | Meco Man <[email protected]> | 2021-02-11 02:32:47 +0800 |
| commit | 5e5ceabfdce8638c5ec8b78d4a53aa2ed0046b82 (patch) | |
| tree | 0fcb796c3b4b1f6eb88c25c4507d0b7c2664d9a7 /components/libc/compilers | |
| parent | 072dbe57c6da6bafb90128720462dd16e92741cd (diff) | |
add ctime_r() and re-implement ctime()
Diffstat (limited to 'components/libc/compilers')
| -rw-r--r-- | components/libc/compilers/common/time.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/components/libc/compilers/common/time.c b/components/libc/compilers/common/time.c index 081e27de74..ff76fae453 100644 --- a/components/libc/compilers/common/time.c +++ b/components/libc/compilers/common/time.c @@ -10,6 +10,7 @@ * 2021-02-05 Meco Man add timegm() * 2021-02-07 Meco Man fixed gettimeofday() * 2021-02-08 Meco Man add settimeofday() stime() + * 2021-02-10 Meco Man add ctime_r() and re-implement ctime() */ #include <sys/time.h> @@ -149,9 +150,15 @@ char* asctime(const struct tm *timeptr) return asctime_r(timeptr, buf); } -char* ctime(const time_t *timep) +char *ctime_r (const time_t * tim_p, char * result) { - return asctime(localtime(timep)); + struct tm tm; + return asctime_r (localtime_r (tim_p, &tm), result); +} + +char* ctime(const time_t *tim_p) +{ + return asctime (localtime (tim_p)); } /** |
