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 Gregorian 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.
-
The input format used to represent the formatters and calendar components.
Declaration
Swift
public var rawValue: String -
The formatter to use when storing the result.
Note
For anRSDAnswerResult, only thedateFormatis saved to the encodedRSDAnswerResultType.dateFormatproperty.Declaration
Swift
public let resultFormatter: DateFormatter -
The formatter used to determine the appropriate date components (by parsing the
dateFormatstring) and the formatter used to parse out aminDateandmaxDatefor a decodedRSDDateRangeObject.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 =
Gregorian
.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
rawValuewhich 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
SingleValueDecodingContainerwith therawValuethat can be used to decode this instance.Declaration
Swift
public init(from decoder: Decoder) throws -
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
:nanosecondDeclaration
Swift
public static func calendarComponents(from format: String) -> Set<Calendar.Component>Parameters
formatThe string to parse.
View on GitHub
RSDDateCoderObject Structure Reference