import Foundation

extension TimeInterval {

    var timeString: String {
        let seconds = Int(rounded())
        guard seconds > 59 else {
            return "\(seconds) s"
        }
        let min = seconds / 60
        let secs = seconds % 60
        guard min > 59 else {
            return String(format: "%02d:%02d", min, secs)
        }
        let hours = min / 60
        let mins = min % 60
        return String(format: "%d:%02d:%02d", hours, mins, secs)
    }
}
