Skip to content
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

Fix strflocaltime on daylight saving time values #2202

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

wjlroe
Copy link

@wjlroe wjlroe commented Oct 29, 2020

This PR changes the way time values get serialised and deserialised to the internal format when passing them between stages. Previously the internal value didn't retain the dst value so time values would lose that field and when printed using strflocaltime, the fact the value was in DST was lost. This seems to me to be the only way to have strflocaltime printing the correct time zone information on values during a daylight saving time.

The following behaviour demonstrates how the daylight savings value gets
lost when a time value gets turned into an internal array of numbers and
then back into a (struct tm):

    $ TZ=Europe/London ./jq -r -n '1504803635 | strflocaltime("%Y-%m-%d %H:%M:%S (%Z)")'
    2017-09-07 18:00:35 (GMT)

After this change however, this works as expected:

    $ TZ=Europe/London ./jq -r -n '1504803635 | strflocaltime("%Y-%m-%d %H:%M:%S (%Z)")'
    2017-09-07 18:00:35 (BST)

(the only difference is in the %Z value - "BST" instead of the incorrect "GMT").

@wjlroe wjlroe changed the title Fix strflocaltime on DST values Fix strflocaltime on daylight saving time values Oct 29, 2020
@coveralls
Copy link

Coverage Status

Coverage increased (+0.2%) to 84.355% when pulling d25af32 on wjlroe:fix-dst-strflocaltime into a17dd32 on stedolan:master.

@pkoppstein
Copy link
Contributor

@wtlangford - I cannot say whether this PR fixes all TZ-related bugs in jq, but I hope that you will keep in mind that the serious TZ-related bugs in jq are "silent" and as such really deserve to be prioritized, even over a release of jq 1.7.

If you're too busy to attend to these "silent" TZ-related bugs yourself, perhaps we could recruit some volunteers to review this particular PR, but if we do so, would you be able at least to try to "pull" the PR if the reviewers attest to its being an improvement? Thanks.

@itchyny
Copy link
Contributor

itchyny commented Aug 11, 2021

Issue: #1912.

The following behaviour demonstrates how the daylight savings value gets
lost when a time value gets turned into an internal array of numbers and
then back into a (struct tm):

        $ TZ=Europe/London ./jq -r -n '1504803635 | strflocaltime("%Y-%m-%d %H:%M:%S (%Z)")'
        2017-09-07 18:00:35 (GMT)

After this change however, this works as expected:

        $ TZ=Europe/London ./jq -r -n '1504803635 | strflocaltime("%Y-%m-%d %H:%M:%S (%Z)")'
        2017-09-07 18:00:35 (BST)
@DehanLUO
Copy link

DehanLUO commented Jan 8, 2023

Branch 439cf72 works for me, thx.

@trantor
Copy link
Contributor

trantor commented Sep 7, 2023

@nicowilliams was this fixed by the recent locale-related patches?

@nicowilliams
Copy link
Contributor

@nicowilliams was this fixed by the recent locale-related patches?

No, sadly.

@chrismo
Copy link

chrismo commented Sep 8, 2023

@nicowilliams was this fixed by the recent locale-related patches?

No, sadly.

I installed 1.7 yesterday and it seemed to have fixed one of my scripts that uses it? /shrug

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants