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
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions src/builtin.c
Original file line number Diff line number Diff line change
Expand Up @@ -1239,7 +1239,8 @@ static jv tm2jv(struct tm *tm) {
jv_number(tm->tm_min),
jv_number(tm->tm_sec),
jv_number(tm->tm_wday),
jv_number(tm->tm_yday));
jv_number(tm->tm_yday),
jv_number(tm->tm_isdst));
}

#if defined(WIN32) && !defined(HAVE_SETENV)
Expand Down Expand Up @@ -1460,12 +1461,9 @@ static int jv2tm(jv a, struct tm *tm) {
TO_TM_FIELD(tm->tm_sec, a, 5);
TO_TM_FIELD(tm->tm_wday, a, 6);
TO_TM_FIELD(tm->tm_yday, a, 7);
TO_TM_FIELD(tm->tm_isdst, a, 8);
jv_free(a);

// We use UTC everywhere (gettimeofday, gmtime) and UTC does not do DST.
// Setting tm_isdst to 0 is done by the memset.
// tm->tm_isdst = 0;

// The standard permits the tm structure to contain additional members. We
// hope it is okay to initialize them to zero, because the standard does not
// provide an alternative.
Expand Down
4 changes: 2 additions & 2 deletions tests/jq.test
Original file line number Diff line number Diff line change
Expand Up @@ -1440,7 +1440,7 @@ bsearch(0,2,4)
# strptime tests are in optional.test

strftime("%Y-%m-%dT%H:%M:%SZ")
[2015,2,5,23,51,47,4,63]
[2015,2,5,23,51,47,4,63,0]
"2015-03-05T23:51:47Z"

strftime("%A, %B %d, %Y")
Expand All @@ -1449,7 +1449,7 @@ strftime("%A, %B %d, %Y")

gmtime
1425599507
[2015,2,5,23,51,47,4,63]
[2015,2,5,23,51,47,4,63,0]

# module system
import "a" as foo; import "b" as bar; def fooa: foo::a; [fooa, bar::a, bar::b, foo::a]
Expand Down
2 changes: 1 addition & 1 deletion tests/man.test
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,7 @@ fromdate

strptime("%Y-%m-%dT%H:%M:%SZ")
"2015-03-05T23:51:47Z"
[2015,2,5,23,51,47,4,63]
[2015,2,5,23,51,47,4,63,0]

strptime("%Y-%m-%dT%H:%M:%SZ")|mktime
"2015-03-05T23:51:47Z"
Expand Down
4 changes: 2 additions & 2 deletions tests/optional.test
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
# strptime() is not available on mingw/WIN32
[strptime("%Y-%m-%dT%H:%M:%SZ")|(.,mktime)]
"2015-03-05T23:51:47Z"
[[2015,2,5,23,51,47,4,63],1425599507]
[[2015,2,5,23,51,47,4,63,0],1425599507]

# Check day-of-week and day of year computations
# (should trip an assert if this fails)
# This date range
last(range(365 * 67)|("1970-03-01T01:02:03Z"|strptime("%Y-%m-%dT%H:%M:%SZ")|mktime) + (86400 * .)|strftime("%Y-%m-%dT%H:%M:%SZ")|strptime("%Y-%m-%dT%H:%M:%SZ"))
null
[2037,1,11,1,2,3,3,41]
[2037,1,11,1,2,3,3,41,0]

# %e is not available on mingw/WIN32
strftime("%A, %B %e, %Y")
Expand Down