DateEncodingStrategy
public enum DateEncodingStrategy
The strategy to use for encoding Date values.
-
Defer to
Datefor choosing an encoding. This is the default strategy.Declaration
Swift
case deferredToDate -
Encode the
Dateas a UNIX timestamp (as a JSON number).Declaration
Swift
case secondsSince1970 -
Encode the
Dateas UNIX millisecond timestamp (as a JSON number).Declaration
Swift
case millisecondsSince1970 -
Encode the
Dateas an ISO-8601-formatted string (in RFC 3339 format).Declaration
Swift
case iso8601 -
Encode the
Dateas a string formatted by the given formatter.Declaration
Swift
case formatted(DateFormatter) -
Encode the
Dateas a custom value encoded by the given closure.If the closure fails to encode a value into the given encoder, the encoder will encode an empty automatic container in its place.
Declaration
Swift
case custom((Date, Encoder) throws -> Void)
View on GitHub
DateEncodingStrategy Enumeration Reference