See #100 for a use case and how to do it with Jiff at time of writing. That is, this issue isn't about adding anything you can't already do with Jiff today, but as the answer I posted in #100 shows, coming up with your own solution to this is a little annoying.
Chrono provides a serde sub-module that handles use cases like this. For example: https://docs.rs/chrono/latest/chrono/serde/ts_seconds_option/index.html
I do like the simplicity of Chrono's approach here. In particular, it avoids defining a new wrapper type for each option, which would be a lot more involved. Instead, you just use it like serde(with = "chrono::serde::ts_seconds_option"). I'm not a huge fan of the naming, but it isn't bad.
So probably we copy Chrono's approach here? I'm struggling to see something better.
It'd be nice to make it "automatic," but we can't really, because I think timestamps in seconds and milliseconds are pretty common and it's impossible to disambiguate between them.
See #100 for a use case and how to do it with Jiff at time of writing. That is, this issue isn't about adding anything you can't already do with Jiff today, but as the answer I posted in #100 shows, coming up with your own solution to this is a little annoying.
Chrono provides a
serdesub-module that handles use cases like this. For example: https://docs.rs/chrono/latest/chrono/serde/ts_seconds_option/index.htmlI do like the simplicity of Chrono's approach here. In particular, it avoids defining a new wrapper type for each option, which would be a lot more involved. Instead, you just use it like
serde(with = "chrono::serde::ts_seconds_option"). I'm not a huge fan of the naming, but it isn't bad.So probably we copy Chrono's approach here? I'm struggling to see something better.
It'd be nice to make it "automatic," but we can't really, because I think timestamps in seconds and milliseconds are pretty common and it's impossible to disambiguate between them.