Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jpmhouston/de82ffa91a9fdb026b39bc6ad65c7c0c to your computer and use it in GitHub Desktop.
Save jpmhouston/de82ffa91a9fdb026b39bc6ad65c7c0c to your computer and use it in GitHub Desktop.
convert TimeInterval to DispatchTimeInterval
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))
}
}
@jpmhouston
Copy link
Author

oh, realize now that this isn't very necessary because Dispatch defines a '+(DispatchTime, Double)'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment