From bd4d9ffb58e36e15689b2cf262687f932d9def52 Mon Sep 17 00:00:00 2001 From: arvinzzz Date: Wed, 28 Dec 2022 16:05:10 +0800 Subject: [PATCH] fixed 2a4282f from https://gitee.com/arvinzzz/kernel_liteos_m/pulls/979 fix: The tm struct obtained by mktime lacks timezone information MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit BREAKING CHANGE: The tm struct obtained by mktime lacks timezone information 变更API: time_t mktime(struct tm *tmptr) 原先mktime从入参中获取时区信息进行计算,变更后tm结构体和返回值time_t的计算使用系统g_timezone时区环境变量。 Close I67UIA Signed-off-by: arvinzzz Change-Id: I766cffbff3c1a25bb33cbd245225ee117909af3a --- kal/posix/src/time.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kal/posix/src/time.c b/kal/posix/src/time.c index ce197223..97e93764 100644 --- a/kal/posix/src/time.c +++ b/kal/posix/src/time.c @@ -664,7 +664,7 @@ static time_t ConvertUtc2Secs(struct tm *tm) seconds += (tm->tm_mday - 1) * SECS_PER_DAY; seconds += tm->tm_hour * SECS_PER_HOUR + tm->tm_min * SECS_PER_MIN + tm->tm_sec; - seconds -= tm->__tm_gmtoff; // sub time zone to get UTC time + seconds += g_timezone; return seconds; } @@ -690,7 +690,7 @@ time_t mktime(struct tm *tmptr) } timeInSeconds = ConvertUtc2Secs(tmptr); /* normalize tm_wday and tm_yday */ - ConvertSecs2Utc(timeInSeconds, tmptr->__tm_gmtoff, tmptr); + ConvertSecs2Utc(timeInSeconds, -g_timezone, tmptr); return timeInSeconds; } -- GitLab