RSDDateRangeObject
public struct RSDDateRangeObject : RSDDateRange, Codable
RSDDateRangeObject
is a concrete implementation of a RSDDateRange
that defines the range of values appropriate
for a date
data type.
-
The minimum allowed date. When the value of this property is
nil
, then theallowPast
property is checked fornil
, otherwiseallowPast
is ignored.Declaration
Swift
public let minDate: Date?
-
The maximum allowed date. When the value of this property is
nil
, then theallowFuture
property is checked fornil
, otherwiseallowFuture
is ignored.Declaration
Swift
public let maxDate: Date?
-
Whether or not the UI should allow future dates. If
nil
or ifmaxDate
is defined then this value is ignored. Default istrue
.Declaration
Swift
public let shouldAllowFuture: Bool?
-
Whether or not the UI should allow past dates. If
nil
or ifminDate
is defined then this value is ignored. Default istrue
.Declaration
Swift
public let shouldAllowPast: Bool?
-
The minute interval to allow for a time picker. A time picker will default to 1 minute if this is
nil
or if the number is outside the allowable range of 1 to 30 minutes.Declaration
Swift
public let minuteInterval: Int?
-
The date encoder to use for formatting the result. If
nil
then the result,minDate
, andmaxDate
are assumed to be used for time and date with the default coding implementation.Declaration
Swift
public let dateCoder: RSDDateCoder?
-
The date that should be set initially.
Declaration
Swift
public let defaultDate: Date?
-
Default initializer.
Declaration
Swift
public init(minimumDate: Date?, maximumDate: Date?, allowFuture: Bool? = nil, allowPast: Bool? = nil, minuteInterval: Int? = nil, dateCoder: RSDDateCoder? = nil, defaultDate: Date? = nil)
Parameters
minimumDate
The minimum allowed date.
maximumDate
The maximum allowed date.
allowFuture
Whether or not the UI should allow future dates.
allowPast
Whether or not the UI should allow past dates.
minuteInterval
The minute interval to allow for a time picker.
dateCoder
The date encoder to use for formatting the result.
-
Convenience initializer for time only
Declaration
Swift
public init(minuteInterval: Int?, defaultTime: String?)
Parameters
minuteInterval
The minute interval to allow for a time picker.
defaultTime
The default time as a string encoded in ISO8601 format.
-
Initialize from a
Decoder
.- example:
Example where the minimum and maximum dates are set to specific values.
{ "minimumDate" : "2017-02-20", "maximumDate" : "2017-03-20", "codingFormat" : "yyyy-MM-dd" }
Example where the range does not allow future dates.
{ "allowFuture" : "false" }
Example where the range does not allow future dates.
{ "allowPast" : "false" }
Example where the time should include hours and minutes, but the minute interval is set to 15 minutes.
{ "minuteInterval" : 15, "defaultDate" : "07:00", "codingFormat" : "HH:mm" }
Throws
DecodingError
Declaration
Swift
public init(from decoder: Decoder) throws
Parameters
decoder
The decoder to use to decode this instance.
-
Encode the object to the given encoder.
Throws
EncodingError
Declaration
Swift
public func encode(to encoder: Encoder) throws
Parameters
encoder
The encoder to use to encode this instance.