DateCodingStrategy
public enum DateCodingStrategy : RawRepresentable
Enum representing the various encoding/decoding strategy pairs for Dates.
Set these on a MongoClient, MongoDatabase, or MongoCollection so that the strategies will be applied when
converting Dates between their BSON representations and their representations in (non BSONDocument) Codable
types.
As per the BSON specification, the default strategy is to encode Dates as BSON datetime objects.
See also
bsonspec.org-
Declaration
Swift
public typealias RawValue = (encoding: BSONEncoder.DateEncodingStrategy, decoding: BSONDecoder.DateDecodingStrategy) -
Encode/decode the
Dateby deferring to its default encoding/decoding implementations.Declaration
Swift
case deferredToDate -
Encode/decode the
Dateto/from a BSON datetime object (default).Declaration
Swift
case bsonDateTime -
Encode/decode the
Dateto/from a 64-bit integer counting the number of milliseconds since January 1, 1970.Declaration
Swift
case millisecondsSince1970 -
Encode/decode the
Dateto/from a BSON double counting the number of seconds since January 1, 1970.Declaration
Swift
case secondsSince1970 -
Encode/decode the
Dateto/from an ISO-8601-formatted string (in RFC 339 format).Declaration
Swift
case iso8601 -
Encode/decode the
Dateto/from a string formatted by the given formatter.Declaration
Swift
case formatted(DateFormatter) -
Encode the
Dateby using the givenencodeFunc. Decode theDateby using the givendecodeFunc. IfencodeFuncdoes 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 }
View on GitHub
Install in Dash
DateCodingStrategy Enumeration Reference