helium / oracles

Oracles for Helium subDAOs
Apache License 2.0
19 stars 21 forks source link

humantime serde #811

Closed michaeldjeffrey closed 4 months ago

michaeldjeffrey commented 4 months ago

Bring Durations and DateTimes into alignment across settings. Companion Ops PR: https://github.com/novalabsxyz/ops/pull/1348

A Bit about Duration

When possible std::time::Duration was preferred in place of chrono::Duration.

If there was a duration or timestamp comparison that looked like negative Durations could be in play chrono::Duration was left. (In future chrono versions they've renamed chrono::Duration to chrono::TimeDelta with the thinking that Duration implies only positive time.)

There are also some tests with chrono::Duration is left in because the constructors added readability. There's a current nightly only feature that will add some of these constructors to std::time::Duration https://github.com/rust-lang/rust/issues/120301

.u(hhhh)nwrap()???

In an attempt to make default duration settings easier to understand, I used humantime::format_duration which returns a result. These are only used in serde default functions.