Skip to content

Instantly share code, notes, and snippets.

@breakstorm
Created February 28, 2017 06:22
Show Gist options
  • Save breakstorm/15ac582a48518934be2a042364d0ba81 to your computer and use it in GitHub Desktop.
Save breakstorm/15ac582a48518934be2a042364d0ba81 to your computer and use it in GitHub Desktop.
process.stdin.resume();
process.stdin.setEncoding('ascii');
var input_stdin = "";
var input_stdin_array = "";
var input_currentline = 0;
process.stdin.on('data', function (data) {
input_stdin += data;
});
process.stdin.on('end', function () {
input_stdin_array = input_stdin.split("\n");
main();
});
function readLine() {
return input_stdin_array[input_currentline++];
}
/////////////// ignore above this line ////////////////////
function main() {
var time = readLine();
//console.log(typeof time);
//PM,AM 인지 확인
//이후 +시간
//출력순서 뒤집기
var status = time.slice(time.length-2, time.length);
var newTime;
if(status=="PM"){
var hour = parseInt(time.slice(0,2));
if(hour===12){
var hourString = hour.toString();
}
else{
var hourTemp = hour+12;
var hourString = hourTemp.toString();
}
newTime = hourString
}
else if(status=="AM"){
newTime = time.slice(0,2);
if(newTime==="12") newTime = "00";
}
//console.log(time.slice(0,2));
for(i=2;i<8;i++){
newTime = newTime+time[i];
}
console.log(newTime);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment