Last active
May 29, 2016 19:50
-
-
Save mattdiamond/45b50dbbec767898b521f3d29ea90dbf 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(' '), | |
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