summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorNicolas Williams <nico@cryptonector.com>2017-05-21 16:24:48 -0500
committerNicolas Williams <nico@cryptonector.com>2017-05-21 16:24:48 -0500
commitc538237f4e4c381d35f1c15497c95f659fd55850 (patch)
tree86ae2d701edc08d00507c600bdff879f0f10916e /tests
parent4a6241be0697bbe4ef420c43689c34af59e50330 (diff)
Deal with strptime() on OS X and *BSD (fix #1415)
strptime() on OS X and *BSDs (reputedly) does not set tm_wday and tm_yday unless corresponding %U and %j format specifiers were used. That can be... surprising when one parsed year, month, and day anyways. Glibc's strptime() conveniently sets tm_wday and tm_yday in those cases, but OS X's does not, ignoring them completely. This commit makes jq compute those where possible, though the day of week computation may be wrong for dates before 1900-03-01 or after 2099-12-31.
Diffstat (limited to 'tests')
-rw-r--r--tests/optional.test7
1 files changed, 6 insertions, 1 deletions
diff --git a/tests/optional.test b/tests/optional.test
index 0ee1fb27..fc37e607 100644
--- a/tests/optional.test
+++ b/tests/optional.test
@@ -2,9 +2,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]
+# Check day-of-week and day of year computations
+# (should trip an assert if this fails)
+last(range(365 * 199)|("1900-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
+[2099,0,10,1,2,3,6,9]
+
# %e is not available on mingw/WIN32
strftime("%A, %B %e, %Y")
1435677542.822351