[swift-users] Decoding dates with dateDecodingStrategy

Ray Fix rayfix at gmail.com
Sun Oct 22 23:24:44 CDT 2017


I had a question about date deserialization.  If a container (or its sub-containers) has dates in multiple formats, is the best way to go about it to decode a string and then run each one through a custom date formatter?

 It seems strange to me that dateDecodingStrategy is a top-level decoder concern rather than being part of an individual date decode method.  In my custom init(from decoder: Decoder) methods, I want to put the knowledge in there instead of relying on something from outside to set it correctly.  Maybe I am missing something?

Thanks as always for any insights you can share with me.

Ray


More information about the swift-users mailing list