增加手动设置时区的功能

This commit is contained in:
Meco Man
2021-05-01 05:51:18 +08:00
parent 79a452b26d
commit a7a3ca9f02
2 changed files with 9 additions and 3 deletions

View File

@@ -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;