解决方法
以下是在
Swift中如何做到这一点:
func parseDuration(timeString:String) -> NSTimeInterval { guard !timeString.isEmpty else { return 0 } var interval:Double = 0 let parts = timeString.componentsSeparatedByString(":") for (index,part) in parts.reverse().enumerate() { interval += (Double(part) ?? 0) * pow(Double(60),Double(index)) } return interval }
它适用于像二时12分12秒,02:01:23.123213