Skip to main content

Module datetime

Module datetime 

Source
Available on crate features chrono or jetstream or service only.
Expand description

Datetime abstraction over the time and chrono backends.

async-nats exposes datetimes on its JetStream and Service APIs through the DateTime alias. The concrete type is selected by the chrono feature:

  • By default, DateTime is time::OffsetDateTime.
  • With the chrono feature enabled, DateTime is chrono::DateTime<chrono::Utc>.

Note: the chrono feature selects the backend for the whole build. Because Cargo unifies features across the dependency graph, enabling chrono anywhere in the graph switches the public type to chrono for every consumer of async-nats in that build. If you depend on the default time backend, be aware a transitive dependency that enables async-nats/chrono will change DateTime to the chrono type.

The chrono backend also stores each instant as an i64 nanosecond count (range roughly the years 1678 to 2262), narrower than the time backend; under chrono, from_nanos returns an error for values outside that range.

Functions§

add_std_durationNon-chrono
Add a std::time::Duration to a DateTime.
from_nanosNon-chrono
Convert a Unix timestamp in nanoseconds to a DateTime.
nowNon-chrono
Return the current time as a UTC DateTime.
parse_rfc3339Non-chrono
Parse an RFC 3339 timestamp into a DateTime (normalized to UTC).

Type Aliases§

DateTimeNon-chrono
The datetime type used across the JetStream and Service APIs.