Skip to content

Commit 3bbf54f

Browse files
committed
test: add timezone handling tests
1 parent 54e9962 commit 3bbf54f

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

tests/shtest

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -665,6 +665,7 @@ $VALGRIND $Q $JQ . <<\NUM
665665
-10E-1000000001
666666
NUM
667667

668+
<<<<<<< Side #1 (Conflict 1 of 1)
668669
# test for --indent and --compact-output -- #1465
669670
printf '[1,2]\n' > $d/expected
670671
$JQ --compact-output -n "[1,2]" > $d/out
@@ -694,4 +695,26 @@ printf '[\n {\n "a": 1\n }\n]\n' > $d/expected
694695
$JQ --indent 6 -n "[{a:1}]" > $d/out
695696
cmp $d/out $d/expected
696697

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

0 commit comments

Comments
 (0)