TimeRange

public struct TimeRange : Equatable, Hashable

Interval between two date-time values.

  • Undocumented

    Declaration

    Swift

    public init(from start: Time, to finish: Time)
  • Undocumented

    Declaration

    Swift

    public var start: Time
  • Duration of the interval (in seconds).

    Declaration

    Swift

    public var duration: TimeInterval { get }
  • Duration of the interval in a specific time unit.

    Declaration

    Swift

    public func duration(in unit: TimeUnit) -> Double
  • Returns the range resulting by adding a specified duration (in seconds) to both start and finish date-times.

    Declaration

    Swift

    public func shiftingBy(duration: TimeInterval) -> TimeRange
  • Returns the range resulting by adding a specified number of days to both start and finish date-times.

    Declaration

    Swift

    public func shiftingBy(days: Int) -> TimeRange
  • Returns the range resulting by adding a specified number of weeks to both start and finish date-times.

    Declaration

    Swift

    public func shiftingBy(weeks: Int) -> TimeRange
  • Returns the range resulting by adding a specified number of hours to both start and finish date-times.

    Declaration

    Swift

    public func shiftingBy(hours: Double) -> TimeRange
  • Returns the range resulting by adding a specified number of minutes to both start and finish date-times.

    Declaration

    Swift

    public func shiftingBy(minutes: Double) -> TimeRange
  • Returns the range resulting by adding a specified number of seconds to both start and finish date-times.

    Declaration

    Swift

    public func shiftingBy(seconds: Double) -> TimeRange
  • Returns the range resulting by adding a specified duration (in a specific time unit) to both start and finish date-times.

    Declaration

    Swift

    public func shiftingBy(duration: Double, in unit: TimeUnit) -> TimeRange
  • Returns the range resulting by adding a specified number of months to both start and finish date-times.

    Declaration

    Swift

    public func shiftingBy(months: MonthInterval) -> TimeRange
  • Returns the range resulting by adding a specified number of years to both start and finish date-times.

    Declaration

    Swift

    public func shiftingBy(years: Int) -> TimeRange
  • Returns the range resulting by adding a specified duration (in a specific calendar time unit) to both start and finish date-times.

    Declaration

    Swift

    public func shiftingBy(duration: Int, in unit: CalendarTimeUnit) -> TimeRange
  • Determines whether the interval contains a specific date-time. Interval limits (start and finish) are considered to be included.

    Declaration

    Swift

    public func contains(_ dateTime: Time) -> Bool
  • Determines whether the interval intersects another interval. Touching interval limits are considered to generate intersection as well.

    Declaration

    Swift

    public func intersects(_ interval: TimeRange) -> Bool
  • Returns the intersection with another interval. Touching interval limits are considered to generate (momentary) intersection as well. Returns nil when intervals don’t intersect.

    Declaration

    Swift

    public func intersecting(_ interval: TimeRange) -> TimeRange?
  • Indicates whether the interval limits are time ordered (start is before finish). Momentary intervals (for which interval limits are equal) are considered entropic as well.

    Declaration

    Swift

    public var isEntropic: Bool { get }
  • Indicates whether the interval limits are equal (start and finish point to the same moment).

    Declaration

    Swift

    public var isMomentary: Bool { get }
  • Returns the current week interval considering the local time zone.

    Declaration

    Swift

    public static var currentWeek: TimeRange { get }
  • Initializes a date-time interval based on the current week, optionally considering the specified time zone (by default the local time zone is used).

    Declaration

    Swift

    public init(for timeZone: TimeZone? = nil)