Struct chrono_elapsed::Elapsed [−][src]
pub struct Elapsed { pub duration: Duration, pub passed: bool, pub cache: HashMap<TimeFrame, (String, i64)>, // some fields omitted }
Expand description
Provides a context-aware DateTime
object; a given DateTime
is made aware in the context of the
current DateTime
(or in the context of a given DateTime
, see new_with_context
.)
Allows you to easily obtain information such as datetime is due in 42 minutes and 30 seconds
,
datetime is overdue by 3 days and 2 hours
, or when given context, time between x and y is 42 years and 9 months
.
Aliased as DueDateTime
out of the box in case that makes more sense in your context.
Fields
duration: Duration
Also known as the diff
, difference in time between a given DateTime
and the `DateTime1 used
for context.
passed: bool
If the date has already passed
, or elapsed
, it’s no longer due
so we can skip some
processing.
cache: HashMap<TimeFrame, (String, i64)>
A cache of diff
values.
Key being the sec/min/hour/day, etc. identifier.
Value being a tuple of the diff
value as a string in pos 0, and numeric value in pos 1.
Implementations
Construct a new object from a Date
rather than DateTime
.
Construct a new object and then add Local
timezone.
Construct a new object from a Date
then add Local
timezone.
Construct a new object with a custom context
, rather than the default now
.
Construct a new object from a Date
with a custom context
.
Set the Elapsed
’s datetime_context. Will clear cached diff
values.
Set the Elapsed
’s datetime. Will clear cached diff
values.
Set the Elapsed
’s date. Will clear cached diff
values.
Default behaviour currently. Discards “irrelevant” time frames, for example if date is due in
more than a year, we’ll only store 1y 6m
as opposed to 1y 6m 2w 4d
.
Helper function to insert a value for a TimeFrame
into the cache.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Elapsed
impl UnwindSafe for Elapsed
Blanket Implementations
Mutably borrows from an owned value. Read more