Created
May 29, 2016 19:49
-
-
Save mattdiamond/18b27ee298ab24156a87927e071f258c to your computer and use it in GitHub Desktop.
a short nodejs script that will convert dates
This file contains 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 node | |
String.prototype.mapLines = function(func){ | |
return this.split("\n").map(func).join("\n"); | |
} | |
function convertDate(line){ | |
if (!line) return line; | |
var split = line.split(' '); | |
var date = new Date(split[0]); | |
split[0] = date.toLocaleString(); | |
split[0] += ' |'; | |
return split.join(' '); | |
} | |
process.stdin.setEncoding('utf8'); | |
process.stdin.on('data', function(data) { | |
process.stdout.write(data.mapLines(convertDate)); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment