You are viewing a single comment's thread. Return to all comments →
Simple solution in C++
` string timeConversion(string s) { int n = s.size(); string hourStr = s.substr(0,2); int hour = std::stoi( hourStr); if (s[n-2]=='P' && hour<12) { hour+=12 ; hourStr = to_string(hour); } if (s[n-2]=='A' && hour==12) { hourStr = "00"; } s = hourStr.append(s.substr(2,n-4)); return s; }
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 →
Simple solution in C++