]> git.ipfire.org Git - thirdparty/systemd.git/commit
time-util: fix issues in parse_timestamp() and optimize performance 38876/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 9 Sep 2025 00:52:45 +0000 (09:52 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 27 Sep 2025 02:52:24 +0000 (11:52 +0900)
commit514fa9d39ae9935ef1e014a3dd48dd5856007df2
treed453bea8f0d1ce9c991d6f05ce367c5ac91d9fbf
parent23407c1806b037ce627a60d60df85a824b23967e
time-util: fix issues in parse_timestamp() and optimize performance

Previously, an input string ends with short timezone spec e.g. WET,
was parsed by setting $TZ environment variable to the timezone.
But the timezone might be different from the original local timezone,
thus the result might not follow the timezone change in the original
local timezone.

This makes the check of the short timezone spec with tzname[] earlier,
then it is not necessary to load another timezone file for e.g. WET,
and provides expected time.

This also make it use SAVE_TIMEZONE macro and drop use of forking
process. This makes greatly improve performance when parsing string
that contains timezone different from the current local timezone.

Unfortunately, there is still one corner case that our test fails.
When tzdata is built with rearguard enabled, then at least
Africa/Windhoek timezone does not provide correct time, but time shifted
1 hour from the original.
src/basic/time-util.c
src/test/test-time-util.c