You are viewing a single comment's thread. Return to all comments →
CPP lang
string timeConversion(string s) { bool isPm = s[8] == 'P' ? true : false; int hh = stoi(s.substr(0,2)); string mm = s.substr(3,2); string ss = s.substr(6,2);
if(!isPm && hh == 12) return "00" + s.substr(2,6); if(isPm && hh == 12) return s.substr(0,8); if(!isPm && hh < 12) return s.substr(0,8); string new_time; int hour = hh + 12; new_time = to_string(hour) + ":" + mm + ":" + ss; return new_time;
}
Seems like cookies are disabled on this browser, please enable them to open this website
Time Conversion
You are viewing a single comment's thread. Return to all comments →
CPP lang
string timeConversion(string s) { bool isPm = s[8] == 'P' ? true : false; int hh = stoi(s.substr(0,2)); string mm = s.substr(3,2); string ss = s.substr(6,2);
}