Skip to content

Instantly share code, notes, and snippets.

@wplong11
Created July 17, 2022 12:33
Show Gist options
  • Select an option

  • Save wplong11/04cb620f44a616289f0068cdb6047f08 to your computer and use it in GitHub Desktop.

Select an option

Save wplong11/04cb620f44a616289f0068cdb6047f08 to your computer and use it in GitHub Desktop.
DispatchTimeIntervalExtension.swift
import Foundation
extension DispatchTimeInterval {
func asTimeInterval() -> TimeInterval {
switch self {
case let .nanoseconds(value): return Double(value) / 1_000_000_000
case let .microseconds(value): return Double(value) / 1_000_000
case let .milliseconds(value): return Double(value) / 1_000
case let .seconds(value): return Double(value)
case .never: return Double.infinity
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment