Last active
February 23, 2017 16:28
-
-
Save awaxa/f7f4693c9601539c087f93631227ff96 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# set -v | |
export TZ=America/Los_Angeles | |
node -e 'console.log(JSON.stringify({date: (new Date).getTime()}))' | jq '.date/1000 | strftime("%Y-%m-%d %H:%M:%S %Z")' | |
export TZ=America/New_York | |
node -e 'console.log(JSON.stringify({date: (new Date).getTime()}))' | jq '.date/1000 | strftime("%Y-%m-%d %H:%M:%S %Z")' | |
export TZ=UTC | |
node -e 'console.log(JSON.stringify({date: (new Date).getTime()}))' | jq '.date/1000 | strftime("%Y-%m-%d %H:%M:%S %Z")' |
Author
awaxa
commented
Feb 23, 2017
For posterity, according to https://developer.apple.com/legacy/library/documentation/Darwin/Reference/ManPages/man3/strptime.3.html
The %Z format specifier only accepts time zone abbreviations of the local time zone, or the value
"GMT". This limitation is because of ambiguity due to of the over loading of time zone abbreviations.
One such example is EST which is both Eastern Standard Time and Eastern Australia Summer Time.
I believe this is cause of what I demonstrated above.
Can you show the inputs that jq is getting? Make it
node -e 'console.log(JSON.stringify({date: (new Date).getTime()}))' | jq '.date/1000 | (., strftime("%Y-%m-%d %H:%M:%S %Z"))'
EDIT: Never mind, I can reproduce this.
Thanks for the bug report!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment