DateEncodingStrategy
public enum DateEncodingStrategy
Enum representing the various strategies for encoding Dates.
As per the BSON specification, the default strategy is to encode Dates as BSON datetime objects.
See also
bsonspec.org-
Encode the
Dateby deferring to its default encoding implementation.Declaration
Swift
case deferredToDate -
Encode the
Dateas a BSON datetime object (default). Throws anEncodingErrorif theDateis further away from January 1, 1970 than can be represented by a 64-bit signed integer of milliseconds.Declaration
Swift
case bsonDateTime -
Encode the
Dateas a 64-bit integer counting the number of milliseconds since January 1, 1970. Throws anEncodingErrorif theDateis too far away from then to be represented this way.Declaration
Swift
case millisecondsSince1970 -
Encode the
Dateas a BSON double counting the number of seconds since January 1, 1970.Declaration
Swift
case secondsSince1970 -
Encode the
Dateas an ISO-8601-formatted string (in RFC 339 format).Declaration
Swift
case iso8601 -
Encode the
Dateas a string formatted by the given formatter.Declaration
Swift
case formatted(DateFormatter) -
Encode the
Dateby using the given closure. If the closure does not encode a value, an empty document will be encoded in its place.Declaration
Swift
case custom((Date, Encoder) throws -> Void)
View on GitHub
Install in Dash
DateEncodingStrategy Enumeration Reference