Created
June 8, 2020 09:52
-
-
Save s/19531b42ac8eef52cf090d2b424d5a80 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
import Foundation | |
public extension TimeInterval { | |
/// `minuteSecondMS` is a convenience computed variable which converts a `TimeInterval` to `mm:ss:ms` format. | |
var minuteSecondMS: String { | |
return String(format: "%d:%02d.%03d", minute, second, millisecond) | |
} | |
/// `minute` is a convenience computed variable which converts a `TimeInterval` to minutes. | |
var minute: Int { | |
return Int((self/60).truncatingRemainder(dividingBy: 60)) | |
} | |
/// `second` is a convenience computed variable which converts a `TimeInterval` to seconds. | |
var second: Int { | |
return Int(truncatingRemainder(dividingBy: 60)) | |
} | |
/// `millisecond` is a convenience computed variable which converts a `TimeInterval` to milliseconds. | |
var millisecond: Int { | |
return Int((self*1000).truncatingRemainder(dividingBy: 1000)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment