Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
kamcma opened this issue Mar 30, 2022 · 0 comments
Open

Comments

@kamcma
Copy link

kamcma commented Mar 30, 2022

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

/// The strategy to use for decoding `Date` values.
public enum DateDecodingStrategy {
/// Defer to `Date` for decoding. This is the default strategy.
case deferredToDate
/// Decode the `Date` as a UNIX timestamp from a XML number. This is the default strategy.
case secondsSince1970

The actual default is .secondsSince1970:

/// The strategy to use in decoding dates. Defaults to `.secondsSince1970`.
open var dateDecodingStrategy: DateDecodingStrategy = .secondsSince1970

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:

/// The strategy to use in encoding dates. Defaults to `.deferredToDate`.
open var dateEncodingStrategy: DateEncodingStrategy = .deferredToDate

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.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant