Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- for tz in America/New_York Europe/Madrid; do
- export TZ="$tz"
- printf 'TZ=%s\n' "$TZ"
- printf 'Expect: '
- printf '2021-08-04T22:55:12+0000\n' |
- perl -M5.010 -MTime::Piece -nle'
- my $epoch = Time::Piece->strptime($_, "%Y-%m-%dT%H:%M:%S%z")->epoch;
- say $epoch;
- say localtime($epoch)->strftime("%Y-%m-%dT%H:%M:%S%z");
- '
- printf 'Got: '
- printf '2021-08-04T22:55:12+0000\n' |
- jq -Rr 'gsub("[+]0000"; "Z") | fromdateiso8601'
- printf '2021-08-04T22:55:12+0000\n' |
- jq -Rr 'gsub("[+]0000"; "Z") | fromdateiso8601 | localtime | strftime("%Y-%m-%dT%H:%M:%S%z")'
- printf '\n'
- done
- TZ=America/New_York
- Expect: 1628117712
- 2021-08-04T18:55:12-0400
- Got: 1628121312
- 2021-08-04T19:55:12+0000
- TZ=Europe/Madrid
- Expect: 1628117712
- 2021-08-05T00:55:12+0200
- Got: 1628121312
- 2021-08-05T01:55:12+0000
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement