RSDDateCoderObject

public struct RSDDateCoderObject : RSDDateCoder, RawRepresentable

RSDDateCoderObject provides a concrete implementation of a RSDDateCoder. The date coder is used by the RSDDateRangeObject to encode and decode the minDate and maxDate properties as well as to get which components of a date should be stored in the answer for a given RSDInputField.

This coder uses ISO 8601 format to determine which calendar components to request from the user and to store from the input result. The calendar is ISO8601 and the resultFormatter is determined from the calendarComponents using the shared RSDFactory or the factory associated with the decoder if instantiated using a Decoder. The locale for the date formatters is en_US_POSIX by default.

  • Coder for a timestamp.

    Declaration

    Swift

    public static let timestamp: RSDDateCoderObject
  • Coder for a date only.

    Declaration

    Swift

    public static let dateOnly: RSDDateCoderObject
  • Coder for a time of day.

    Declaration

    Swift

    public static let timeOfDay: RSDDateCoderObject
  • Coder for a time of day.

    Declaration

    Swift

    public static let hourAndMinutesOnly: RSDDateCoderObject
  • The input format used to represent the formatters and calendar components.

    Declaration

    Swift

    public var rawValue: String { get }
  • The formatter to use when storing the result.

    Note

    For an RSDAnswerResult, only the dateFormat is saved to the encoded RSDAnswerResultType.dateFormat property.

    Declaration

    Swift

    public let resultFormatter: DateFormatter
  • The formatter used to determine the appropriate date components (by parsing the dateFormat string) and the formatter used to parse out a minDate and maxDate for a decoded RSDDateRangeObject.

    Declaration

    Swift

    public let inputFormatter: DateFormatter
  • The components to request from the user and to store.

    Declaration

    Swift

    public let calendarComponents: Set<Calendar.Component>
  • The calendar used by the associated input field. Default = ISO8601.

    Declaration

    Swift

    public let calendar: Calendar
  • The default initializer initializes the date coder as a timestamp.

    Declaration

    Swift

    public init()
  • Initialize the date coder using the rawValue which is the input date format.

    Declaration

    Swift

    public init?(rawValue: String)
  • Initialize the date coder using a decoder. The decoder is assumed to have a SingleValueDecodingContainer with the rawValue that can be used to decode this instance.

    Declaration

    Swift

    public init(from decoder: Decoder) throws
  • Encode the rawValue to a SingleValueEncodingContainer.

    Declaration

    Swift

    public func encode(to encoder: Encoder) throws

    Parameters

    encoder

    The encoder to encode the rawValue to.

  • The is a static method used to parse the ISO 8601 date format for the calendar components that are relavent to this instance. This method inspects the given string for the components where: - yyyy: year - MM: month - dd: day - HH: hour - mm: minute - ss: second - ss.SSS: nanosecond

    Declaration

    Swift

    public static func calendarComponents(from format: String) -> Set<Calendar.Component>

    Parameters

    format

    The string to parse.