Trait DurationRound
trait DurationRound: Sized
Extension trait for rounding or truncating a DateTime by a TimeDelta.
Limitations
Both rounding and truncating are done via TimeDelta::num_nanoseconds and
DateTime::timestamp_nanos_opt. This means that they will fail if either the
TimeDelta or the DateTime are too big to represented as nanoseconds. They
will also fail if the TimeDelta is bigger than the timestamp, negative or zero.
Associated Types
type Err: TraitBound { trait_: Path { path: "std::error::Error", id: Id(253), args: None }, generic_params: [], modifier: None }Error that can occur in rounding or truncating
Required Methods
fn duration_round(self: Self, duration: TimeDelta) -> Result<Self, <Self as >::Err>Return a copy rounded by TimeDelta.
Example
# use ; let dt = from_ymd_opt .unwrap .and_hms_milli_opt .unwrap .and_utc; assert_eq!; assert_eq!;fn duration_trunc(self: Self, duration: TimeDelta) -> Result<Self, <Self as >::Err>Return a copy truncated by TimeDelta.
Example
# use ; let dt = from_ymd_opt .unwrap .and_hms_milli_opt .unwrap .and_utc; assert_eq!; assert_eq!;
Implementors
impl DurationRound for crate::NaiveDateTimeimpl<Tz: TimeZone> DurationRound for crate::DateTime<Tz>