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,
DateTimeistime::OffsetDateTime. - With the
chronofeature enabled,DateTimeischrono::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_ duration Non- chrono - Add a
std::time::Durationto aDateTime. - from_
nanos Non- chrono - Convert a Unix timestamp in nanoseconds to a
DateTime. - now
Non- chrono - Return the current time as a UTC
DateTime. - parse_
rfc3339 Non- chrono - Parse an RFC 3339 timestamp into a
DateTime(normalized to UTC).
Type Aliases§
- Date
Time Non- chrono - The datetime type used across the JetStream and Service APIs.