Skip to content

Case

JSONEncoder.DateEncodingStrategy.custom(_:)

iOS 8.0+ iPadOS 8.0+ Mac Catalyst 8.0+ macOS 10.10+ tvOS 9.0+ watchOS 2.0+
The strategy that formats custom dates by calling a user-defined function.
@preconcurrency case custom(@Sendable (Date, any Encoder) throws -> Void)

Discussion

If the closure fails to encode a value into the given encoder, the encoder will encode an empty automatic container in its place.