Created
October 15, 2016 09:23
-
-
Save bananafish911/62afd599f499b840ad6ee4c49249bf1b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension TimeInterval { | |
// builds string in app's labels format 00:00.0 | |
func stringFormatted() -> String { | |
var miliseconds = self.roundTo(places: 1) * 10 | |
miliseconds = miliseconds.truncatingRemainder(dividingBy: 10) | |
let interval = Int(self) | |
let seconds = interval % 60 | |
let minutes = (interval / 60) % 60 | |
return String(format: "%02d:%02d.%.f", minutes, seconds, miliseconds) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment