jq
jq copied to clipboard
Fix strflocaltime on daylight saving time values
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").
Coverage increased (+0.2%) to 84.355% when pulling d25af32d80db0573a436b65f63fe5bb146a7abca on wjlroe:fix-dst-strflocaltime into a17dd3248a666d01be75f6b16be37e80e20b0954 on stedolan:master.
@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.
Issue: #1912.
Branch 439cf72 works for me, thx.
@nicowilliams was this fixed by the recent locale-related patches?
@nicowilliams was this fixed by the recent locale-related patches?
No, sadly.
@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