TemporalSpec

public protocol TemporalSpec

The TemporalSpec protocol defines an ISO-8601 formatted Date value. Types that conform to this protocol are responsible for providing the parsing and formatting logic with the correct granularity.

  • A static builder that return an instance that represent the current point in time.

    Declaration

    Swift

    static func now() -> Self
  • The underlying Date object. All TemporalSpec implementations must be backed by a Foundation Date instance.

    Declaration

    Swift

    var foundationDate: Foundation.Date { get }
  • iso8601String Default implementation

    The ISO-8601 formatted string in the UTC TimeZone.

    See also

    iso8601FormattedString(TemporalFormat, TimeZone) -> String

    Default Implementation

    The ISO8601 representation of the scalar using .full as the format and .utc as TimeZone.

    See also

    iso8601FormattedString(format:timeZone:)

    Declaration

    Swift

    var iso8601String: String { get }
  • init(iso8601String:) Default implementation

    Parses an ISO-8601 String into a TemporalSpec.

    Note

    if no timezone is present in the string, .autoupdatingCurrent is used.

    • Parameters

      • iso8601String: the string in the ISO8601 format

    Throws

    DataStoreError.decodeError in case the provided string is not formatted as expected by the scalar type.

    Important

    This will cycle through all available formats for the concrete type. If you know the format, use init(iso8601String:format:) throws instead.

    Default Implementation

    Declaration

    Swift

    init(iso8601String: String) throws
  • init(iso8601String:format:) Default implementation

    Parses an ISO-8601 String into a TemporalSpec.

    Note

    if no timezone is present in the string, .autoupdatingCurrent is used.

    Throws

    DataStoreError.decodeError in case the provided string is not formatted as expected by the scalar type.

    Default Implementation

    Declaration

    Swift

    init(iso8601String: String, format: TemporalFormat) throws
  • Constructs a TemporalSpec from a Date object.

    Declaration

    Swift

    init(_ date: Foundation.Date)

    Parameters

    date

    The Date instance that will be used as the reference of the TemporalSpec instance.

  • A string representation of the underlying date formatted using ISO8601 rules.

    Default Implementation

    Create an iso8601 String with the desired format option for this spec.

    Declaration

    Swift

    func iso8601FormattedString(format: TemporalFormat, timeZone: TimeZone) -> String

    Parameters

    format

    the desired TemporalFormat.

    timeZone

    the target TimeZone

    Return Value

    the ISO8601 formatted string in the requested format

Available where Self: DateUnitOperable

Available where Self: Codable

  • init(from:) Extension method

    Declaration

    Swift

    public init(from decoder: Decoder) throws
  • encode(to:) Extension method

    Declaration

    Swift

    public func encode(to encoder: Encoder) throws

Available where Self: Comparable

  • ==(_:_:) Extension method

    Declaration

    Swift

    public static func == (lhs: Self, rhs: Self) -> Bool
  • <(_:_:) Extension method

    Declaration

    Swift

    public static func < (lhs: Self, rhs: Self) -> Bool

Available where Self: TimeUnitOperable