Skip to content

Commit 372b2af

Browse files
committed
test: add timezone handling tests
1 parent 54e9962 commit 372b2af

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

tests/shtest

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -694,4 +694,26 @@ printf '[\n {\n "a": 1\n }\n]\n' > $d/expected
694694
$JQ --indent 6 -n "[{a:1}]" > $d/out
695695
cmp $d/out $d/expected
696696

697+
if ! $msys && ! $mingw; then
698+
# Test handling of timezones -- #2429, #2475
699+
if ! r=$(TZ=Asia/Tokyo $JQ -rn '1731627341 | strflocaltime("%F %T %z %Z")') \
700+
|| [ "$r" != "2024-11-15 08:35:41 +0900 JST" ]; then
701+
echo "Incorrectly formatted local time"
702+
exit 1
703+
fi
704+
705+
if ! r=$(TZ=Europe/Paris $JQ -rn '1731627341 | strflocaltime("%F %T %z %Z")') \
706+
|| [ "$r" != "2024-11-15 00:35:41 +0100 CET" ]; then
707+
echo "Incorrectly formatted local time"
708+
exit 1
709+
fi
710+
711+
if ! r=$(TZ=Europe/Paris $JQ -rn '1731627341 | strftime("%F %T %z %Z")') \
712+
|| ( [ "$r" != "2024-11-14 23:35:41 +0000 UTC" ] \
713+
&& [ "$r" != "2024-11-14 23:35:41 +0000 GMT" ] ); then
714+
echo "Incorrectly formatted universal time"
715+
exit 1
716+
fi
717+
fi
718+
697719
exit 0

0 commit comments

Comments
 (0)