CoreOffice / XMLCoder

Easy XML parsing using Codable protocols in Swift
https://coreoffice.github.io/XMLCoder/
MIT License
793 stars 104 forks source link

XMLDecoder.DateDecodingStrategy commented and actual default do not match #238

Open kamcma opened 2 years ago

kamcma commented 2 years ago

A couple of the XMLDecoder.DateDecodingStrategy cases describe themselves as the default:

https://github.com/CoreOffice/XMLCoder/blob/394ddf67af04d2221735fa67ea0a374f3473ddf6/Sources/XMLCoder/Decoder/XMLDecoder.swift#L17-L23

The actual default is .secondsSince1970: https://github.com/CoreOffice/XMLCoder/blob/394ddf67af04d2221735fa67ea0a374f3473ddf6/Sources/XMLCoder/Decoder/XMLDecoder.swift#L241-L242

I'm wondering if just the comment or the default value is wrong. XMLEncoder's default is .deferredToDate, which matches the behavior of JSONEncoder and JSONDecoder:

https://github.com/CoreOffice/XMLCoder/blob/394ddf67af04d2221735fa67ea0a374f3473ddf6/Sources/XMLCoder/Encoder/XMLEncoder.swift#L290-L291

Perhaps there is a reason the default date decoding and encoding strategies are different? If not, is the desired behavior that they both be .deferredToDate like JSONEncoder and JSONDecoder? Would it be considered a breaking change to make that fix?

(I should add this has not affected me in production, I have only recently begun exploring this library.)