This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new fbd6484532 libc/localtime: fix the timezone error caused by minor error
fbd6484532 is described below
commit fbd6484532ad17e474a8ccdbd70c4aa1be83995d
Author: dongjiuzhu1 <[email protected]>
AuthorDate: Mon Oct 23 14:26:08 2023 +0800
libc/localtime: fix the timezone error caused by minor error
align: https://github.com/eggert/tz/blob/main/localtime.c
correct timeone in test:
server> timedatectl set-timezone Pacific/Auckland
server> timedatectl
TimeZone: NZDT, 46800
Local time: Sat, Oct 21 21:47:34 2023 NZDT
Universal time: Sat, Oct 21 08:47:34 2023 UTC
RTC time: Sat, Oct 21 08:47:35 2023
error timezone:
server> timedatectl set-timezone Pacific/Auckland
server> timedatectl
TimeZone: NZST, 43200
Local time: Sat, Oct 21 20:52:27 2023 NZST
Universal time: Sat, Oct 21 08:52:27 2023 UTC
RTC time: Sat, Oct 21 08:52:27 2023
Signed-off-by: dongjiuzhu1 <[email protected]>
---
libs/libc/time/lib_localtime.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/libs/libc/time/lib_localtime.c b/libs/libc/time/lib_localtime.c
index a777c87a1d..c6e979010c 100644
--- a/libs/libc/time/lib_localtime.c
+++ b/libs/libc/time/lib_localtime.c
@@ -812,6 +812,10 @@ static int tzload(FAR const char *name,
*/
memset(&sp->chars[i], 0, CHARS_EXTRA);
+
+ /* Read leap seconds, discarding those out of time_t range. */
+
+ leapcnt = 0;
for (i = 0; i < sp->leapcnt; ++i)
{
int_fast64_t tr = stored == 4 ? detzcode(p) : detzcode64(p);
@@ -1717,7 +1721,7 @@ static int tzparse(FAR const char *name, FAR struct
state_s *sp,
janoffset + endtime) &&
atlo <= sp->ats[timecnt])
{
- sp->types[timecnt++] = !reversed;
+ sp->types[timecnt++] = reversed;
}
}