CPCCalendarUnitBackingType

internal protocol CPCCalendarUnitBackingType : Hashable

Common protocol for types that are suitable as backing storage of CPCCalendarUnit instances.

  • Type for which this one serves as a backing storage.

    Declaration

    Swift

    associatedtype BackedType : CPCCalendarUnit
  • init(containing:calendar:) Default implementation

    Creates a new storage for a calendar unit that contains a specific date.

    Default Implementation

    Declaration

    Swift

    init(containing date: Date, calendar: Calendar)

    Parameters

    date

    The date that should be contained in the backed calendar unit.

    calendar

    Calendar to perform calculations with.

  • startDate(using:) Default implementation

    Get an earliest date that is contained in a backed calendar unit.

    Default Implementation

    Declaration

    Swift

    func startDate(using calendar: Calendar) -> Date

    Parameters

    calendar

    Calendar to perform calculations with.

    Return Value

    Earliest date of the represented calendar unit.

  • distance(to:using:) Default implementation

    Calculate distance between this value and other one, measured in the unit’s durations.

    Default Implementation

    Declaration

    Swift

    func distance(to other: Self, using calendar: Calendar) -> Int

    Parameters

    other

    An instance of backing value to calculate distance to.

    calendar

    Calendar to perform calculations with.

    Return Value

    Number of represented calendar units between starts of corresponding date intervals.

  • advanced(by:using:) Default implementation

    Calculate a backing value with specific distance from represented one.

    Default Implementation

    Declaration

    Swift

    func advanced(by value: Int, using calendar: Calendar) -> Self

    Parameters

    value

    Distance from this value.

    calendar

    Calendar to perform calculations with.

    Return Value

    Instance of backing value for which represented unit’s start date is advanced by value unit durations.