Rocket icon indicating copy to clipboard operation
Rocket copied to clipboard

There is no overlap between date types with Deserialize and FromFormField

Open etsea117 opened this issue 3 years ago • 1 comments

Existing Functionality

I want to include a field in an entity for recording the date of a monetary transaction. FromFormField is implemented on PrimitiveDateTime but not DateTime. Deserialize/Serialize is implemented on DateTime but not PrimitiveDateTime. FromFormField is implemented on Date but Deserialize/Serialize is not.

This is quite frustrating for me.

Suggested Changes

Is there a way to get one of those types to be implemented on both FromFormField Deserialize/Serialize?

etsea117 avatar Jul 31 '22 21:07 etsea117

You can create a newtype around PrimitiveDateTime or DateTime, the one you prefer the most, and manually implement both of these traits yourself. Or you simply use both and do an explicit conversion when appropriate. I'll need a bit more context if you want more precise help.

edgarogh avatar Aug 28 '22 18:08 edgarogh

It looks like PrimitiveDateTime now implements (de)serialize! So this was passively fulfilled.

SergioBenitez avatar Apr 05 '23 17:04 SergioBenitez