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

Setup Decoder to decode (FIR)Timestamp to (NS)Date #44

Open
benrudhart opened this issue May 21, 2018 · 10 comments
Open

Setup Decoder to decode (FIR)Timestamp to (NS)Date #44

benrudhart opened this issue May 21, 2018 · 10 comments

Comments

@benrudhart
Copy link

Now that Firestore warns us to/ forces the usage of Timestamps over Dates I'm looking for a way to workaround this.
Background: I'm using Models on iOS and watchOS as well. Firebase is not ready for watchOS hence I cannot use Timestamp in the models. Besides this I'd prefer to avoid the Firestore dependency in my models. The precision of Date is more than enough for me.
My models are also contained in a framework that is not aware of Firebase, hence I cannot implement/ override the decoder that parses the Timestamps into Dates.

Question: Is there a way to setup the FirestoreDecoder to automatically parse Timestamps to Dates when a Date is expected in a model?

@kristofersdundurs
Copy link

Would really love a solution for this as well!
I'm personally not very fond of timestamps. It's essentally rendering CodableFirebase obsolete for a lot of people until we crack it. It's breaking my models apart

@ArEnSc
Copy link

ArEnSc commented Jul 8, 2018

Did anyone fix this problem ?

@andreasmpet
Copy link

Seconding this sentiment. Any progress here?

@ghost
Copy link

ghost commented Dec 24, 2018

Still no fix?

@agordeev
Copy link

It'd be great to see such mapping in this library. Exposing Firebase Timestamp type to models is something all developers should stay away of.

@jimijon
Copy link

jimijon commented Feb 18, 2019

Can we get this fixed? It is now breaking everything

@siyao1030
Copy link

+1.

Updated to the latest Firestore for their new groupCollection query method, but now it gives me this error when I run the app.

Swift.DecodingError.typeMismatch(Foundation.Date, Swift.DecodingError.Context(codingPath: [CodingKeys(stringValue: "createdAt", intValue: nil)], debugDescription: "Expected to decode Date but found FIRTimestamp instead.", underlyingError: nil))

@nikitaame
Copy link

+1

@nikolausWest
Copy link

1+

@mshershnev
Copy link

Hi guys.

I fixed that issue.

Here you can find solution: https://github.com/mshershnev/CodableFirebase
Code example is here: #86 (comment)

I did pull request and hope that it will be merged soon: #86

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

10 participants