libc/time: Fix POSIX timezone string parsing - #19516
Conversation
|
nuttx-tz-after.log |
When loading a zoneinfo file fails, parse a non-colon-prefixed TZ value as a POSIX timezone string. Treat a successful tzparse() result as success while preserving the leading-colon file-only behavior. Assisted-by: Codex:gpt-5.6 Sol Signed-off-by: hanzhijian <hanzhijian@zepp.com>
79a34c3 to
a9a1149
Compare
|
@Zepp-Hanzj did you test with https://nuttx.apache.org/docs/latest/components/libs/libc/zoneinfo.html ? |
version.log My previous validation did not enable CONFIG_LIBC_ZONEINFO. I have now retested the current PR with the documented sim:nsh ROMFS configuration: |
Summary
This addresses the POSIX timezone parsing part of #19446. The reported ROMFS
archive build error is not changed here because it did not reproduce on the
current master branch.
Root cause
The conditions around
tzparse()were inverted. The fallback was attemptedonly for names beginning with
:, and a parse failure was treated as success.As a result, ordinary POSIX TZ strings such as
ART3andJST-9fell back toUTC instead of applying their offsets.
Validation
Tested with
sim:nshusing:The simulator was rebuilt from
make distcleanbefore both runs.Observed before this change:
Observed after this change:
ART3now applies UTC-3,JST-9applies UTC+9, and:ART3remainsfile-only and falls back to UTC when that file is unavailable.
Additional checks:
make -j$(nproc)tools/checkpatch.sh -f libs/libc/time/lib_localtime.c