Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add timezone handling tests
Browse files Browse the repository at this point in the history
marcin-serwin committed Jan 26, 2025
1 parent 52c8ea6 commit 465ca66
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/shtest
Original file line number Diff line number Diff line change
@@ -665,4 +665,25 @@ $VALGRIND $Q $JQ . <<\NUM
-10E-1000000001
NUM

# Test handling of timezones -- #2429, #2475

if ! r=$(TZ=Asia/Tokyo $JQ -rn '1731627341 | strflocaltime("%F %T %z %Z")') \
|| [ "$r" != "2024-11-15 08:35:41 +0900 JST" ]; then
echo "Incorrectly formatted local time"
exit 1
fi

if ! r=$(TZ=Europe/Paris $JQ -rn '1731627341 | strflocaltime("%F %T %z %Z")') \
|| [ "$r" != "2024-11-15 00:35:41 +0100 CET" ]; then
echo "Incorrectly formatted local time"
exit 1
fi

if ! r=$(TZ=Europe/Paris $JQ -rn '1731627341 | strftime("%F %T %z %Z")') \
|| ( [ "$r" != "2024-11-14 23:35:41 +0000 UTC" ] \
&& [ "$r" != "2024-11-14 23:35:41 +0000 GMT" ] ); then
echo "Incorrectly formatted universal time"
exit 1
fi

exit 0

0 comments on commit 465ca66

Please sign in to comment.