From b74022e2c4274698aa26a18cbd6df72842f8ac38 Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Thu, 15 Apr 2021 14:31:23 +0800 Subject: [PATCH] mktime support fixed timezone --- components/libc/compilers/common/time.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/components/libc/compilers/common/time.c b/components/libc/compilers/common/time.c index 75adb817da..638735b77c 100644 --- a/components/libc/compilers/common/time.c +++ b/components/libc/compilers/common/time.c @@ -234,7 +234,13 @@ RTM_EXPORT(localtime); /* TODO: timezone */ time_t mktime(struct tm * const t) { - return timegm(t); + time_t timestamp; + int utc_plus; + + utc_plus = 8; /* GMT: UTC+8 */ + timestamp = timegm(t); + timestamp = timestamp - 3600 * utc_plus; + return timestamp; } RTM_EXPORT(mktime);