Last active
January 2, 2017 02:49
-
-
Save ScalaWilliam/2cd79a9e2703b062fca66bedb0b6ba59 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/jjs | |
function cstTime(unixTime) { | |
var instant = java.time.Instant.ofEpochSecond(unixTime); | |
var zoned = instant.atZone(java.time.ZoneId.of("America/New_York")); | |
return java.time.format.DateTimeFormatter.ISO_ZONED_DATE_TIME.format(zoned); | |
} | |
java.nio.file.Files.lines( | |
java.nio.file.Paths.get("/dev/stdin") | |
).map(JSON.parse) | |
.map(function(obj) { obj.iso_timestamp = cstTime(obj.unix_timestamp); return obj; }) | |
.map(JSON.stringify) | |
.forEach(print); | |
/* | |
Usage: | |
./add-ny-time-json.js << EOF | |
{"unix_timestamp": 1552134142} | |
{"unix_timestamp": 1552134143} | |
{"unix_timestamp": 1562134142} | |
EOF | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment