diff options
-rw-r--r-- | common/sys/time.c | 14 | ||||
-rw-r--r-- | include/cmsys.h | 10 |
2 files changed, 21 insertions, 3 deletions
diff --git a/common/sys/time.c b/common/sys/time.c index 7cf963b3..7a3768c1 100644 --- a/common/sys/time.c +++ b/common/sys/time.c @@ -112,6 +112,20 @@ struct tm *localtime4(const time4_t *t) } } +struct tm* +localtime4_r(const time4_t *t, struct tm *pt) +{ + if (t) + { + time_t temp = (time_t)*t; + localtime_r(&temp, pt); + } + else + localtime_r(NULL, pt); + return pt; +} + + time4_t time4(time4_t *ptr) { if( ptr == NULL ) diff --git a/include/cmsys.h b/include/cmsys.h index abb66213..a50793fe 100644 --- a/include/cmsys.h +++ b/include/cmsys.h @@ -113,11 +113,15 @@ extern const char* Cdatelite(const time4_t *clock); extern const char* Cdatedate(const time4_t * clock); extern const char * Cdate_mdHM(const time4_t * clock); extern const char* my_ctime(const time4_t * t, char *ans, int len); +extern struct tm localtime4r(const time4_t *t); + #ifdef TIMET64 - struct tm *localtime4(const time4_t *); - time4_t time4(time4_t *); - char *ctime4(const time4_t *); + struct tm* localtime4(const time4_t *); + struct tm* localtime4_r(const time4_t *, struct tm *); + time4_t time4(time4_t *); + char* ctime4(const time4_t *); #else + #define localtime4_r(a,b) localtime_r(a,b) #define localtime4(a) localtime(a) #define time4(a) time(a) #define ctime4(a) ctime(a) |