Date

public extension Date
extension Date: @retroactive Strideable
  • Compares another date to this one, with a day (24 hours) granularity.

    Declaration

    Swift

    func isOnADayBefore(_ inDay: Date, calendar inCalendar: Calendar? = nil) -> Bool

    Parameters

    inDay

    The date against which we are comparing ourselves.

    calendar

    An optional (default is the current calendar) calendar instance, to use for the calculation.

    Return Value

    True, if this date is on a day prior to the one provided.

  • Compares another date to this one, with a day (24 hours) granularity.

    Declaration

    Swift

    func isOnADayAfter(_ inDay: Date, calendar inCalendar: Calendar? = nil) -> Bool

    Parameters

    inDay

    The date against which we are comparing ourselves.

    calendar

    An optional (default is the current calendar) calendar instance, to use for the calculation.

    Return Value

    True, if this date is on a day after the one provided.

  • Compares another date to this one, with a day (24 hours) granularity.

    Declaration

    Swift

    func isOnTheSameDayAs(_ inDay: Date, calendar inCalendar: Calendar? = nil) -> Bool

    Parameters

    inDay

    The date against which we are comparing ourselves.

    calendar

    An optional (default is the current calendar) calendar instance, to use for the calculation.

    Return Value

    True, if this date is the same day as the one provided.

Date Extension, To Allow Striding

  • The distance of a stride.

    Declaration

    Swift

    public func distance(to inOther: Date) -> TimeInterval

    Parameters

    to

    The other date instance we are measuring.

    Return Value

    The number of seconds that separate the two dates.

  • This advances the stride by the iteration amount given.

    Declaration

    Swift

    public func advanced(by inInterval: TimeInterval) -> Date

    Parameters

    by

    The iteration amount (in seconds).

    Return Value

    The new date instance.