From 7b2371f0ed6ebe9d842bcb9b39d1024a1f3adaea Mon Sep 17 00:00:00 2001 From: dongjiuzhu1 Date: Wed, 14 Sep 2022 20:56:53 +0800 Subject: [PATCH] libc/localtime: fix timegm return error when tz with isdst testcase: set TZ CEST time_t t = time(NULL); struct tm *ts = localtime(&t); t = timegm(ts); t will return (time_t)-1; Signed-off-by: dongjiuzhu1 --- libs/libc/time/lib_localtime.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libs/libc/time/lib_localtime.c b/libs/libc/time/lib_localtime.c index 5164c7ab09..e089482387 100644 --- a/libs/libc/time/lib_localtime.c +++ b/libs/libc/time/lib_localtime.c @@ -2584,5 +2584,10 @@ time_t mktime(FAR struct tm *tmp) time_t timegm(FAR struct tm *tmp) { + if (tmp != NULL) + { + tmp->tm_isdst = 0; + } + return time1(tmp, gmtsub, 0L); }