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
descriptions anddebugDescriptions.Declaration
Swift
static var descriptionDateFormatTemplate: String { get } -
calendarDefault implementationDefault Implementation
Undocumented
Declaration
Swift
var calendar: Calendar { get } -
Unit’s calendar that is wrapped in
CalendarWrapperobject 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
valueBacking value representing calendar unit.
calendarCalendar to perform various calculations with.
-
CalendarWrapperExtension methodUndocumented
Declaration
Swift
internal typealias CalendarWrapper = CPCCalendarWrapper -
startExtension methodDeclaration
Swift
@inlinable public var start: Date { get } -
endExtension 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
-
descriptionExtension methodDeclaration
Swift
public var description: String { get } -
debugDescriptionExtension methodDeclaration
Swift
public var debugDescription: String { get }
-
CommonCacheKeyExtension 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
otherCalendar unit to fetch distance to.
Return Value
Distance from this unit to
otheror 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
distanceDistance between this unit and
otherthat is being cached.otherUnit, 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
strideRequired 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
valueCalendar unit that is being cached.
distanceDistance 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) -> SelfParameters
keyType of the unit cached.
View on GitHub
Install in Dash
CPCCalendarUnit Protocol Reference