DateCodingStrategy
public enum DateCodingStrategy : RawRepresentable
Enum representing the various encoding/decoding strategy pairs for Date
s.
Set these on a MongoClient
, MongoDatabase
, or MongoCollection
so that the strategies will be applied when
converting Date
s between their BSON representations and their representations in (non BSONDocument
) Codable
types.
As per the BSON specification, the default strategy is to encode Date
s as BSON datetime objects.
See also
bsonspec.org-
Declaration
Swift
public typealias RawValue = (encoding: BSONEncoder.DateEncodingStrategy, decoding: BSONDecoder.DateDecodingStrategy)
-
Encode/decode the
Date
by deferring to its default encoding/decoding implementations.Declaration
Swift
case deferredToDate
-
Encode/decode the
Date
to/from a BSON datetime object (default).Declaration
Swift
case bsonDateTime
-
Encode/decode the
Date
to/from a 64-bit integer counting the number of milliseconds since January 1, 1970.Declaration
Swift
case millisecondsSince1970
-
Encode/decode the
Date
to/from a BSON double counting the number of seconds since January 1, 1970.Declaration
Swift
case secondsSince1970
-
Encode/decode the
Date
to/from an ISO-8601-formatted string (in RFC 339 format).Declaration
Swift
case iso8601
-
Encode/decode the
Date
to/from a string formatted by the given formatter.Declaration
Swift
case formatted(DateFormatter)
-
Encode the
Date
by using the givenencodeFunc
. Decode theDate
by using the givendecodeFunc
. IfencodeFunc
does not encode a value, an empty document will be encoded in its place.Declaration
Swift
case custom(encodeFunc: (Date, Encoder) throws -> Void, decodeFunc: (Decoder) throws -> Date)
-
Declaration
Swift
public init?(rawValue: RawValue)
-
Declaration
Swift
public var rawValue: RawValue { get }