DateEncodingStrategy
public enum DateEncodingStrategy
Enum representing the various strategies for encoding Date
s.
As per the BSON specification, the default strategy is to encode Date
s as BSON datetime objects.
See also
bsonspec.org-
Encode the
Date
by deferring to its default encoding implementation.Declaration
Swift
case deferredToDate
-
Encode the
Date
as a BSON datetime object (default). Throws anEncodingError
if theDate
is further away from January 1, 1970 than can be represented by a 64-bit signed integer of milliseconds.Declaration
Swift
case bsonDateTime
-
Encode the
Date
as a 64-bit integer counting the number of milliseconds since January 1, 1970. Throws anEncodingError
if theDate
is too far away from then to be represented this way.Declaration
Swift
case millisecondsSince1970
-
Encode the
Date
as a BSON double counting the number of seconds since January 1, 1970.Declaration
Swift
case secondsSince1970
-
Encode the
Date
as an ISO-8601-formatted string (in RFC 339 format).Declaration
Swift
case iso8601
-
Encode the
Date
as a string formatted by the given formatter.Declaration
Swift
case formatted(DateFormatter)
-
Encode the
Date
by 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)