Skip to content

Commit

Permalink
test: add timezone handling tests
Browse files Browse the repository at this point in the history
  • Loading branch information
marcin-serwin committed Jan 27, 2025
1 parent 52c8ea6 commit e3f94dd
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/shtest
Original file line number Diff line number Diff line change
Expand Up @@ -665,4 +665,26 @@ $VALGRIND $Q $JQ . <<\NUM
-10E-1000000001
NUM

if ! $msys && ! $mingw; then
# 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
fi

exit 0

0 comments on commit e3f94dd

Please sign in to comment.