diff options
Diffstat (limited to 'components/libc/compilers')
| -rw-r--r-- | components/libc/compilers/common/time.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/components/libc/compilers/common/time.c b/components/libc/compilers/common/time.c index 72542867d2..deda18a560 100644 --- a/components/libc/compilers/common/time.c +++ b/components/libc/compilers/common/time.c @@ -30,6 +30,10 @@ #define DBG_LVL DBG_INFO #include <rtdbg.h> +#ifndef RT_LIBC_FIXED_TIMEZONE +#define RT_LIBC_FIXED_TIMEZONE 8 /* UTC+8 */ +#endif + /* seconds per day */ #define SPD 24*60*60 @@ -208,14 +212,11 @@ struct tm* gmtime(const time_t* t) } RTM_EXPORT(gmtime); -/*TODO: timezone */ struct tm* localtime_r(const time_t* t, struct tm* r) { time_t local_tz; - int utc_plus; - utc_plus = 8; /* GMT: UTC+8 */ - local_tz = *t + utc_plus * 3600; + local_tz = *t + RT_LIBC_FIXED_TIMEZONE * 3600; return gmtime_r(&local_tz, r); } RTM_EXPORT(localtime_r); @@ -227,15 +228,12 @@ struct tm* localtime(const time_t* t) } RTM_EXPORT(localtime); -/* TODO: timezone */ time_t mktime(struct tm * const t) { time_t timestamp; - int utc_plus; - utc_plus = 8; /* GMT: UTC+8 */ timestamp = timegm(t); - timestamp = timestamp - 3600 * utc_plus; + timestamp = timestamp - 3600 * RT_LIBC_FIXED_TIMEZONE; return timestamp; } RTM_EXPORT(mktime); |
