-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
time-util: fix using wrong timezone when parsing timestamp #38876
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
aa3f3f1
to
0eaa857
Compare
0eaa857
to
095dbbb
Compare
095dbbb
to
f676327
Compare
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.
f676327
to
514fa9d
Compare
@YHNdnzj Thank you for the review. Addressed comments. PTAL. |
|
||
if (tmp.return_value == 0 && ret) | ||
*ret = tmp.usec; | ||
if (setenv("TZ", strjoina(":", tz), /* overwrite = */ true) < 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not your fault, but the latest man pages for tzset states:
A nonempty value of TZ can be one of two formats, either of which can be preceded by a colon which is ignored.
hence the prefix should be dropped across the codebase
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, but I will do that later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-> #39160.
glibc (and also musl, though we do not officially support it yet) silently ignores colon prefix in $TZ. Let's always not prefix the timezone. tzset(3) states: > A nonempty value of TZ can be one of two formats, either of which can > be preceded by a colon which is ignored. Addresses systemd#38876 (comment).
glibc (and also musl, though we do not officially support it yet) silently ignores colon prefix in $TZ. Let's always not prefix the timezone. tzset(3) states: > A nonempty value of TZ can be one of two formats, either of which can > be preceded by a colon which is ignored. Addresses systemd#38876 (comment).
glibc (and also musl, though we do not officially support it yet) silently ignores colon prefix in $TZ. Let's always not prefix the timezone. tzset(3) states: > A nonempty value of TZ can be one of two formats, either of which can > be preceded by a colon which is ignored. Addresses systemd#38876 (comment).
glibc (and also musl, though we do not officially support it yet) silently ignores colon prefix in $TZ. Let's always not prefix the timezone. tzset(3) states: > A nonempty value of TZ can be one of two formats, either of which can > be preceded by a colon which is ignored. Addresses systemd#38876 (comment).
glibc (and also musl, though we do not officially support it yet) silently ignores colon prefix in $TZ. Let's always not prefix the timezone. tzset(3) states: > A nonempty value of TZ can be one of two formats, either of which can > be preceded by a colon which is ignored. Addresses systemd#38876 (comment).
glibc (and also musl, though we do not officially support it yet) silently ignores colon prefix in $TZ. Let's always not prefix the timezone. tzset(3) states: > A nonempty value of TZ can be one of two formats, either of which can > be preceded by a colon which is ignored. Addresses systemd#38876 (comment).
This mostly fixes issues workarounded several times, e.g. #28472 and #35471.