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

Coders with Date as Double in schema #130

Open
ZirgVoice opened this issue Nov 13, 2023 · 0 comments
Open

Coders with Date as Double in schema #130

ZirgVoice opened this issue Nov 13, 2023 · 0 comments

Comments

@ZirgVoice
Copy link

I use secondsSince1970 to decode and encode date in Coders. In Fluent the createdAt field is of type Date, so that the frontend doesn't have problems I convert it to Double in the schema, and it seems that the standard decoder/encoder deferredToDate starts to be used, because in the response to the request comes 721570737.092619 instead of 1699877937.092619. I also tried converting to String, same result.

Config coders.decoder.dateDecodingStrategy:

    coders.decoder.dateDecodingStrategy = .secondsSince1970
    coders.encoder.dateEncodingStrategy = .secondsSince1970

Field in schema:

            Field("createdAt", at: \.createdAt, as: Double?.self)
            Field("updatedAt", at: \.updatedAt, as: Double?.self)
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