Skip to content

Conversation

yuwata
Copy link
Member

@yuwata yuwata commented Sep 10, 2025

This mostly fixes issues workarounded several times, e.g. #28472 and #35471.

@github-actions github-actions bot added util-lib tests please-review PR is ready for (re-)review by a maintainer labels Sep 10, 2025
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.
@yuwata
Copy link
Member Author

yuwata commented Sep 27, 2025

@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)
Copy link
Member

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

Copy link
Member Author

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-> #39160.

@YHNdnzj YHNdnzj added good-to-merge/waiting-for-ci 👍 PR is good to merge, but CI hasn't passed at time of review. Please merge if you see CI has passed good-to-merge/with-minor-suggestions and removed please-review PR is ready for (re-)review by a maintainer good-to-merge/waiting-for-ci 👍 PR is good to merge, but CI hasn't passed at time of review. Please merge if you see CI has passed labels Sep 27, 2025
@yuwata yuwata merged commit 3e843e9 into systemd:main Sep 28, 2025
54 of 56 checks passed
@yuwata yuwata deleted the time-util-fix branch September 28, 2025 00:49
yuwata added a commit to yuwata/systemd that referenced this pull request Sep 28, 2025
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).
yuwata added a commit to yuwata/systemd that referenced this pull request Sep 28, 2025
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).
yuwata added a commit to yuwata/systemd that referenced this pull request Sep 28, 2025
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).
yuwata added a commit to yuwata/systemd that referenced this pull request Sep 29, 2025
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).
yuwata added a commit to yuwata/systemd that referenced this pull request Sep 29, 2025
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).
yuwata added a commit to yuwata/systemd that referenced this pull request Sep 29, 2025
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).
YHNdnzj added a commit that referenced this pull request Sep 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants