提交 a7a3ca9f 编写于 作者: mysterywolf's avatar mysterywolf

增加手动设置时区的功能

上级 79a452b2
......@@ -55,8 +55,14 @@ endif
if RT_USING_LIBC != y
config RT_LIBC_USING_TIME
bool "Enable TIME FUNCTIONS WITHOUT COMPILER'S LIBC"
bool "Enable time functions without compiler's libc"
default y
endif
config RT_LIBC_FIXED_TIMEZONE
depends on (RT_LIBC_USING_TIME || RT_USING_LIBC)
int "Manually set a fixed time zone (UTC+)"
range -12 12
default 8
endmenu
......@@ -214,7 +214,7 @@ struct tm* localtime_r(const time_t* t, struct tm* r)
time_t local_tz;
int utc_plus;
utc_plus = 8; /* GMT: UTC+8 */
utc_plus = RT_LIBC_FIXED_TIMEZONE;
local_tz = *t + utc_plus * 3600;
return gmtime_r(&local_tz, r);
}
......@@ -233,7 +233,7 @@ time_t mktime(struct tm * const t)
time_t timestamp;
int utc_plus;
utc_plus = 8; /* GMT: UTC+8 */
utc_plus = RT_LIBC_FIXED_TIMEZONE;
timestamp = timegm(t);
timestamp = timestamp - 3600 * utc_plus;
return timestamp;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册