zebra_chain::serialization::arbitrary

Function datetime_full

source
pub fn datetime_full() -> impl Strategy<Value = DateTime<Utc>>
Expand description

Returns a strategy that produces an arbitrary chrono::DateTime<Utc>, based on the full valid range of the type.

Both the seconds and nanoseconds values are randomised, including leap seconds: https://docs.rs/chrono/0.4.19/chrono/naive/struct.NaiveTime.html#leap-second-handling

Wherever possible, Zebra should handle leap seconds by:

  • making durations and intervals 3 seconds or longer,
  • avoiding complex time-based calculations, and
  • avoiding relying on subsecond precision or time order.

When monotonic times are needed, use the opaque std::time::Instant type.

ยงUsage

Zebra uses these times internally, typically via Utc::now.

Some parts of the Zcash network protocol (Version messages) also use times with an 8-byte seconds value. Unlike this function, they have zero nanoseconds values. (So they never have chrono leap seconds.)