Created
May 11, 2017 22:12
-
-
Save jpmhouston/de82ffa91a9fdb026b39bc6ad65c7c0c to your computer and use it in GitHub Desktop.
convert TimeInterval to DispatchTimeInterval
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
public extension TimeInterval { | |
public var dispatchInterval: DispatchTimeInterval { | |
let microseconds = Int64(self * TimeInterval(USEC_PER_SECS)) // perhaps use nanoseconds, though would more often be > Int.max | |
return microseconds < Int.max ? DispatchTimeInterval.microseconds(Int(microseconds)) : DispatchTimeInterval.seconds(Int(self)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
oh, realize now that this isn't very necessary because Dispatch defines a '+(DispatchTime, Double)'