VirtualTimeConverterType

public protocol VirtualTimeConverterType

Parametrization for virtual time used by VirtualTimeSchedulers.

  • Virtual time unit used that represents ticks of virtual clock.

    Declaration

    Swift

    associatedtype VirtualTimeUnit
  • Virtual time unit used to represent differences of virtual times.

    Declaration

    Swift

    associatedtype VirtualTimeIntervalUnit
  • Converts virtual time to real time.

    Declaration

    Swift

    func convertFromVirtualTime(_ virtualTime: VirtualTimeUnit) -> RxTime

    Parameters

    virtualTime

    Virtual time to convert to Date.

    Return Value

    Date corresponding to virtual time.

  • Converts real time to virtual time.

    Declaration

    Swift

    func convertToVirtualTime(_ time: RxTime) -> VirtualTimeUnit

    Parameters

    time

    Date to convert to virtual time.

    Return Value

    Virtual time corresponding to Date.

  • Converts from virtual time interval to TimeInterval.

    Declaration

    Swift

    func convertFromVirtualTimeInterval(_ virtualTimeInterval: VirtualTimeIntervalUnit) -> TimeInterval

    Parameters

    virtualTimeInterval

    Virtual time interval to convert to TimeInterval.

    Return Value

    TimeInterval corresponding to virtual time interval.

  • Converts from TimeInterval to virtual time interval.

    Declaration

    Swift

    func convertToVirtualTimeInterval(_ timeInterval: TimeInterval) -> VirtualTimeIntervalUnit

    Parameters

    timeInterval

    TimeInterval to convert to virtual time interval.

    Return Value

    Virtual time interval corresponding to time interval.

  • Offsets virtual time by virtual time interval.

    Declaration

    Swift

    func offsetVirtualTime(_ time: VirtualTimeUnit, offset: VirtualTimeIntervalUnit) -> VirtualTimeUnit

    Parameters

    time

    Virtual time.

    offset

    Virtual time interval.

    Return Value

    Time corresponding to time offsetted by virtual time interval.

  • This is additional abstraction because Date is unfortunately not comparable. Extending Date with Comparable would be too risky because of possible collisions with other libraries.

    Declaration

    Swift

    func compareVirtualTime(_ lhs: VirtualTimeUnit, _ rhs: VirtualTimeUnit) -> VirtualTimeComparison