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

dateEncodingFormatter inconsitent format?HI, #116

Closed
b00tsy opened this issue Feb 2, 2019 · 4 comments
Closed

dateEncodingFormatter inconsitent format?HI, #116

b00tsy opened this issue Feb 2, 2019 · 4 comments

Comments

@b00tsy
Copy link

b00tsy commented Feb 2, 2019

Excellent framework which makes my live a lot easier! Although the learning curve could be less steep as I believe that the auto-generated documentation is out of date.

I have problems with dateEncodingFormatter of Coding. Is there a reason why the used format differs from the ones defined in dateDecodingFormatters?

yyyy-MM-dd'T'HH:mm:ss.Z the dot just before Z seems wrong to me and it makes my swagger validator on the backend reject the submitted date, eg. 2019-01-01T12:12:12.Z. On top of that I need fractional accuracy as in one of the formats in the decoding formatter. Is it possible to customize the encoding formatter somehow without manually adjusting Coding.swift every time after an export?

@yonaskolb
Copy link
Owner

Hi @b00tsy, glad you’re getting some use of of it! Those date formatters are public properties so they can be modified. You can just set DateTime.dateEncodingFormatter.formatString = “...”.
The reason why decoding uses an array of formatters is so it can decode a few different types, as backend formats can vary slightly. On encoding though we have to have a single explicit format

@b00tsy
Copy link
Author

b00tsy commented Feb 3, 2019 via email

@yonaskolb
Copy link
Owner

Yeah I'm not sure actually. I think a backend on a project a few years ago must of passed strings back in that format, so it's been there ever since

@yonaskolb
Copy link
Owner

I'll close this for now. Let me know if you have any more questions or issues

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

2 participants