Skip to content

Instantly share code, notes, and snippets.

@mattdiamond
Created May 29, 2016 19:49
Show Gist options
  • Save mattdiamond/18b27ee298ab24156a87927e071f258c to your computer and use it in GitHub Desktop.
Save mattdiamond/18b27ee298ab24156a87927e071f258c to your computer and use it in GitHub Desktop.
a short nodejs script that will convert dates
#!/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