Skip to content

Instantly share code, notes, and snippets.

@skrosoft
Created October 2, 2015 03:40
Show Gist options
  • Save skrosoft/56ad54fe29bf11074a1f to your computer and use it in GitHub Desktop.
Save skrosoft/56ad54fe29bf11074a1f to your computer and use it in GitHub Desktop.
function processData(input) {
var is_pm = input.indexOf('PM') != -1;
var s = input.replace('PM', '').replace('AM', '').split(':');
if (is_pm && s[0] != '12') s[0] = parseInt(s[0]) + 12;
if (!is_pm && s[0] == '12') s[0] = '00';
process.stdout.write(s[0] + ':' + s[1] + ':' + s[2]);
}
process.stdin.resume();
process.stdin.setEncoding("ascii");
_input = "";
process.stdin.on("data", function (input) {
_input += input;
});
process.stdin.on("end", function () {
processData(_input);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment