You are viewing a single comment's thread. Return to all comments →
mine in swift:
func timeConversion(s: String) -> String { if(s.contains("PM")){ let time = s.components(separatedBy: "PM")[0].components(separatedBy: ":") let hour = Int(time[0]) == 12 ? 12 : Int(time[0])!+12 return "\(String(format: "%02d", arguments: [hour])):\(time[1]):\(time[2])" } else{ let time = s.components(separatedBy: "AM")[0].components(separatedBy: ":") let hour = Int(time[0]) == 12 ? 0 : Int(time[0])! return "\(String(format: "%02d", arguments: [hour])):\(time[1]):\(time[2])" } }
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 →
mine in swift: