DateInterval

public extension DateInterval
  • Returns true if self fully overlaps with interval

    Declaration

    Swift

    func fullyOverlaps(with interval: DateInterval) -> Bool

    Parameters

    interval

    interval to compare with

  • Returns true if self partially overlaps with interval

    Declaration

    Swift

    func partiallyOverlaps(with interval: DateInterval) -> Bool

    Parameters

    interval

    interval to compare with

  • Return the duration in hours, truncated to the nearest lower integer

    Declaration

    Swift

    var durationHours: Int { get }
  • Return seconds from hours

    Declaration

    Swift

    internal static func secondsFromHours(_ hours: Int) -> TimeInterval

    Parameters

    hours

    whole hours to convert to seconds

    Return Value

    seconds

  • Intitialize from startDate (truncating to the whole hour) and duration

    Declaration

    Swift

    init?(startDate: Date, durationHours: Int = 1)

    Parameters

    startDate

    start

    durationHours

    hours

  • Return a two-year interval around the data

    Declaration

    Swift

    static func twoYearsAround(date: Date) -> DateInterval

    Parameters

    date

    center of the interval

    Return Value

    DateInterval

  • Return true if the interval is fully in the future, false otherwise

    Declaration

    Swift

    var isInTheFuture: Bool { get }
  • Declaration

    Swift

    var brief: String { get }