Struct TimeDelta Copy item path Source pub struct TimeDelta {
pub months: i32 ,
pub inner: TimeDelta ,
}Expand description Represents a duration of time with both months and a more precise duration.
This struct combines a number of months with a chrono::Duration to represent
time intervals that may include calendar-specific units (months) as well as
fixed-length durations.
§ Fields
months: The number of months in the time delta.
inner: A chrono::Duration representing the precise duration beyond whole months.
§ Serialization
When the “serde” feature is enabled, this struct can be serialized and deserialized.
Parse timedelta from string
for example: “2y1mo-3d5h-2m3s”
Parses a string representation of a duration into a TimeDelta.
This function supports a variety of time units and can handle complex duration strings.
§ Supported Units
ns: nanoseconds
us: microseconds
ms: milliseconds
s: seconds
m: minutes
h: hours
d: days
w: weeks
mo: months
y: years
The duration string should be in the format of <number><unit>, and multiple such pairs can be combined.
For example: “2y1mo-3d5h-2m3s” represents 2 years, 1 month, minus 3 days, 5 hours, minus 2 minutes, and 3 seconds.
§ Arguments
duration - A string slice that holds the duration to be parsed.
§ Returns
TResult<Self> - A Result containing the parsed TimeDelta if successful, or an error if parsing fails.
§ Examples
use tea_time::TimeDelta;
let td = TimeDelta::parse("1y2mo3d4h5m6s" ).unwrap();
assert_eq! (td.months, 14 ); assert_eq! (td.inner, chrono::Duration::seconds(3 * 86400 + 4 * 3600 + 5 * 60 + 6 ));The resulting type after applying the + operator.
The resulting type after applying the + operator.
The resulting type after applying the + operator.
Source § Available on crate feature time only.
Casts the value to the target type
T.
Read more Casts the value to the target type
T.
Read more Casts the value to the target type
T.
Read more Casts the value to the target type
T.
Read more Casts the value to the target type
T.
Read more Source § Available on crate feature time only.
Casts the value to the target type
T.
Read more Casts the value to the target type
T.
Read more Casts the value to the target type
T.
Read more Casts the value to the target type
T.
Read more Casts the value to the target type
T.
Read more Source § Available on crate feature time only.
Casts the value to the target type
T.
Read more Source § Available on crate feature time only.
Casts the value to the target type
T.
Read more Source § Available on crate feature time only.
Casts the value to the target type
T.
Read more Source § Available on crate feature time only.
Casts the value to the target type
T.
Read more Source § Available on crate feature time only.
Casts the value to the target type
T.
Read more Source § Available on crate feature time only.
Casts the value to the target type
T.
Read more Source § Available on crate feature time only.
Casts the value to the target type
T.
Read more Source § Available on crate feature time only.
Casts the value to the target type
T.
Read more Source § Available on crate feature time only.
Casts the value to the target type
T.
Read more Source § Available on crate feature time only.
Casts the value to the target type
T.
Read more Source § Available on crate feature time only.
Casts the value to the target type
T.
Read more Source § Available on crate feature time only.
Casts the value to the target type
T.
Read more Source § Available on crate feature time only.
Casts the value to the target type
T.
Read more Source § Available on crate feature time only.
Casts the value to the target type
T.
Read more Source § Available on crate feature time only.
Casts the value to the target type
T.
Read more Source § Available on crate feature time only.
Casts the value to the target type
T.
Read more Source § Available on crate feature time only.
Casts the value to the target type
T.
Read more Source § Available on crate feature time only.
Casts the value to the target type
T.
Read more Source § Available on crate feature time only.
Casts the value to the target type
T.
Read more Source § Available on crate feature time only.
Casts the value to the target type
T.
Read more Source § Available on crate feature time only.
Casts the value to the target type
T.
Read more Source § Available on crate feature time only.
Casts the value to the target type
T.
Read more Casts the value to the target type
T.
Read more Casts the value to the target type
T.
Read more Casts the value to the target type
T.
Read more Casts the value to the target type
T.
Read more Source § Available on crate feature time only.
Casts the value to the target type
T.
Read more Casts the value to the target type
T.
Read more Casts the value to the target type
T.
Read more Casts the value to the target type
T.
Read more Casts the value to the target type
T.
Read more Performs copy-assignment from
source.
Read more Formats the value using the given formatter.
Read more Returns the “default value” for a type.
Read more The resulting type after applying the / operator.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
The associated error which can be returned from parsing.
Parses a string
s to return a value of this type.
Read more Returns the DataType corresponding to the implementing type.
Read more Source § Available on crate feature time only.
Checks if the value is in the “none” state.
Read more Creates a new instance of
Self in the “none” state.
Read more Converts the value to an
Option<Self::Inner>.
Read more Converts the value to an
Option<&Self::Inner>.
Read more Creates a new instance of
Self from the given inner value.
Read more Casts the inner type of
Self to a new type
U.
Read more Maps a function over the inner value of
Self, if it exists.
Read more Creates a new instance of Self from an Option<Self::Inner>.
Compares two values for sorting, treating
None as the largest value.
Read more Compares two values for reverse sorting, treating
None as the largest value.
Read more The resulting type after applying the * operator.
The resulting type after applying the - operator.
Tests for self and other values to be equal, and is used by ==.
Tests for !=. The default implementation is almost always sufficient,
and should not be overridden without very good reason.
This method returns an ordering between
self and
other values if one exists.
Read more Tests less than (for
self and
other) and is used by the
< operator.
Read more Tests less than or equal to (for
self and
other) and is used by the
<= operator.
Read more Tests greater than (for
self and
other) and is used by the
>
operator.
Read more Tests greater than or equal to (for
self and
other) and is used by
the
>= operator.
Read more The resulting type after applying the - operator.
The resulting type after applying the - operator.
The resulting type after applying the - operator.
Immutably borrows from an owned value.
Read more Mutably borrows from an owned value.
Read more Casts the value to the target type
T.
Read more Casts the value to the target type
T.
Read more 🔬 This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from
self to
dest.
Read more Returns the argument unchanged.
Calls U::from(self).
That is, this conversion is whatever the implementation of
From <T> for U chooses to do.
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning.
Read more Uses borrowed data to replace owned data, usually by cloning.
Read more The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.