PastPeriodFromNow
public struct PastPeriodFromNow : Hashable, Codable
Represents a period from point in the past to now, defined in days,weeks, months or years.
-
Calendar components for constructing a period.
See moreDeclaration
Swift
public enum CalendarUnit : String, Hashable, Codable
-
Returns a calendar unit of the period.
Declaration
Swift
public let unit: CalendarUnit
-
Returns number of calendar units in the period.
Declaration
Swift
public let value: Int
-
Returns a period from one
unit
component in the past to now.Declaration
Swift
public static func past(_ unit: CalendarUnit) -> PastPeriodFromNow
Parameters
unit
Calendar unit of desired period.
-
Returns a period from
value * unit
components in the past to now.Even though there is no formal precondition for the upper limmit of
value
, providing an extremely large number may result in a crash. That can, however, only happen by a programming mistake, as the only meaningful values are those that result in period’s start date not lower than 14 August 1991, the date when arXiv.org was launched.Precondition
value > 0
Declaration
Swift
public static func past(_ value: Int, unit: CalendarUnit) -> PastPeriodFromNow
Parameters
value
Number calendar units in desired period.
unit
Calendar unit of desired period.
-
Returns a date interval representation of the period.
Declaration
Swift
public var dateInterval: DateInterval { get }