CPCCalendarUnit
internal protocol CPCCalendarUnit : CPCCalendarUnitBase
Common protocol implementing most of CPCDay, CPCWeek, CPCMonth and CPCYear functionality.
-
Type serving as a storage for calendar unit info.
Declaration
Swift
associatedtype BackingType : CPCCalendarUnitBackingType
-
Calendar unit that is represented by this model type.
Declaration
Swift
static var representedUnit: Calendar.Component { get }
-
DateFormatter-compatible string to generate
description
s anddebugDescription
s.Declaration
Swift
static var descriptionDateFormatTemplate: String { get }
-
calendar
Default implementationDefault Implementation
Undocumented
Declaration
Swift
var calendar: Calendar { get }
-
Unit’s calendar that is wrapped in
CalendarWrapper
object for performance reasons.Declaration
Swift
var calendarWrapper: CalendarWrapper { get }
-
Raw
value of calendar unit, e.g. month and year values forCPCMonth
.Declaration
Swift
var backingValue: BackingType { get }
-
Creates a new calendar unit.
Declaration
Swift
init(backedBy value: BackingType, calendar: CalendarWrapper)
Parameters
value
Backing value representing calendar unit.
calendar
Calendar to perform various calculations with.
-
CalendarWrapper
Extension methodUndocumented
Declaration
Swift
internal typealias CalendarWrapper = CPCCalendarWrapper
-
start
Extension methodDeclaration
Swift
@inlinable public var start: Date { get }
-
end
Extension methodDeclaration
Swift
@inlinable public var end: Date { get }
-
==(_:_:)
Extension methodDeclaration
Swift
public static func == (lhs: Self, rhs: Self) -> Bool
-
hash(into:)
Extension methodDeclaration
Swift
public func hash(into hasher: inout Hasher)
-
init(containing:calendar:)
Extension methodDeclaration
Swift
@usableFromInline internal convenience init(containing date: Date, calendar: CalendarWrapper)
-
init(containing:calendarOf:)
Extension methodUndocumented
Declaration
Swift
public convenience init(containing date: Date, calendarOf otherUnit: CPCDay)
-
init(containing:calendarOf:)
Extension methodUndocumented
Declaration
Swift
public convenience init(containing date: Date, calendarOf otherUnit: CPCWeek)
-
init(containing:calendarOf:)
Extension methodUndocumented
Declaration
Swift
public convenience init(containing date: Date, calendarOf otherUnit: CPCMonth)
-
init(containing:calendarOf:)
Extension methodUndocumented
Declaration
Swift
public convenience init(containing date: Date, calendarOf otherUnit: CPCYear)
-
distance(to:)
Extension methodDeclaration
Swift
public func distance(to other: Self) -> Int
-
advanced(by:)
Extension methodDeclaration
Swift
public func advanced(by n: Int) -> Self
-
description
Extension methodDeclaration
Swift
public var description: String { get }
-
debugDescription
Extension methodDeclaration
Swift
public var debugDescription: String { get }
-
CommonCacheKey
Extension methodSee CPCCommonCalendarUnitCackeKey.
Declaration
Swift
internal typealias CommonCacheKey = CPCCommonCalendarUnitCacheKey
-
cachedDistance(to:)
Extension methodQuery calendar units cache for distance between two units.
Declaration
Swift
internal func cachedDistance(to other: Self) -> Stride?
Parameters
other
Calendar unit to fetch distance to.
Return Value
Distance from this unit to
other
or nil if no such value was previously cached. -
cacheDistance(_:to:)
Extension methodCache a distance between two calendar units.
Declaration
Swift
internal func cacheDistance(_ distance: Stride, to other: Self)
Parameters
distance
Distance between this unit and
other
that is being cached.other
Unit, distance to which is being cached.
-
cachedAdvancedUnit(by:)
Extension methodQuery calendar units cache for a unit that has specific distance from this one.
Declaration
Swift
internal func cachedAdvancedUnit(by stride: Self.Stride) -> Self?
Parameters
stride
Required distance between units.
Return Value
Unit that has requested distance from this one or nil if no such value was previously cached.
-
cacheUnitValue(_:advancedBy:)
Extension methodCache a calendar unit that has specific distance from this one.
Declaration
Swift
internal func cacheUnitValue(_ value: Self, advancedBy distance: Stride)
Parameters
value
Calendar unit that is being cached.
distance
Distance to the unit that is being cached.
-
cachedCommonUnit(for:calendar:)
Extension methodCache a caclendar unit as a frequently used one for the specified key.
Declaration
Swift
internal static func cachedCommonUnit(for key: CommonCacheKey, calendar: CPCCalendarWrapper) -> Self
Parameters
key
Type of the unit cached.