Skip to content

Commit 465ca66

Browse files
committed
test: add timezone handling tests
1 parent 52c8ea6 commit 465ca66

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

tests/shtest

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

668+
# Test handling of timezones -- #2429, #2475
669+
670+
if ! r=$(TZ=Asia/Tokyo $JQ -rn '1731627341 | strflocaltime("%F %T %z %Z")') \
671+
|| [ "$r" != "2024-11-15 08:35:41 +0900 JST" ]; then
672+
echo "Incorrectly formatted local time"
673+
exit 1
674+
fi
675+
676+
if ! r=$(TZ=Europe/Paris $JQ -rn '1731627341 | strflocaltime("%F %T %z %Z")') \
677+
|| [ "$r" != "2024-11-15 00:35:41 +0100 CET" ]; then
678+
echo "Incorrectly formatted local time"
679+
exit 1
680+
fi
681+
682+
if ! r=$(TZ=Europe/Paris $JQ -rn '1731627341 | strftime("%F %T %z %Z")') \
683+
|| ( [ "$r" != "2024-11-14 23:35:41 +0000 UTC" ] \
684+
&& [ "$r" != "2024-11-14 23:35:41 +0000 GMT" ] ); then
685+
echo "Incorrectly formatted universal time"
686+
exit 1
687+
fi
688+
668689
exit 0

0 commit comments

Comments
 (0)