Enum RoundingError

enum RoundingError

An error from rounding by TimeDelta

See: DurationRound

Variants

DurationExceedsTimestamp

Error when the TimeDelta exceeds the TimeDelta from or until the Unix epoch.

Note: this error is not produced anymore.

DurationExceedsLimit

Error when TimeDelta.num_nanoseconds exceeds the limit.

# use chrono::{DurationRound, TimeDelta, RoundingError, NaiveDate};
let dt = NaiveDate::from_ymd_opt(2260, 12, 31)
    .unwrap()
    .and_hms_nano_opt(23, 59, 59, 1_75_500_000)
    .unwrap()
    .and_utc();

assert_eq!(
    dt.duration_round(TimeDelta::try_days(300 * 365).unwrap()),
    Err(RoundingError::DurationExceedsLimit)
);
TimestampExceedsLimit

Error when DateTime.timestamp_nanos exceeds the limit.

# use chrono::{DurationRound, TimeDelta, RoundingError, TimeZone, Utc};
let dt = Utc.with_ymd_and_hms(2300, 12, 12, 0, 0, 0).unwrap();

assert_eq!(
    dt.duration_round(TimeDelta::try_days(1).unwrap()),
    Err(RoundingError::TimestampExceedsLimit)
);

Implementations

impl Clone for RoundingError

fn clone(self: &Self) -> RoundingError

impl Copy for RoundingError

impl Debug for RoundingError

fn fmt(self: &Self, f: &mut $crate::fmt::Formatter<'_>) -> $crate::fmt::Result

impl Display for RoundingError

fn fmt(self: &Self, f: &mut fmt::Formatter<'_>) -> fmt::Result

impl Eq for RoundingError

impl Error for RoundingError

fn description(self: &Self) -> &str

impl Freeze for RoundingError

impl PartialEq for RoundingError

fn eq(self: &Self, other: &RoundingError) -> bool

impl RefUnwindSafe for RoundingError

impl Send for RoundingError

impl StructuralPartialEq for RoundingError

impl Sync for RoundingError

impl Unpin for RoundingError

impl UnwindSafe for RoundingError

impl<T> Any for RoundingError

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for RoundingError

fn borrow(self: &Self) -> &T

impl<T> BorrowMut for RoundingError

fn borrow_mut(self: &mut Self) -> &mut T

impl<T> CloneToUninit for RoundingError

unsafe fn clone_to_uninit(self: &Self, dest: *mut u8)

impl<T> From for RoundingError

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> ToOwned for RoundingError

fn to_owned(self: &Self) -> T
fn clone_into(self: &Self, target: &mut T)

impl<T> ToString for RoundingError

fn to_string(self: &Self) -> String

impl<T, U> Into for RoundingError

fn into(self: Self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom for RoundingError

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

impl<T, U> TryInto for RoundingError

fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>