Enum RoundingError

pub 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)
);

Trait Implementations

impl Clone for RoundingError

fn clone(&self) -> RoundingError

impl Copy for RoundingError

impl Debug for RoundingError

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

impl Display for RoundingError

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

impl Eq for RoundingError

impl Error for RoundingError

fn description(&self) -> &str

impl PartialEq for RoundingError

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

impl StructuralPartialEq for RoundingError

Auto Trait Implementations

impl Freeze for RoundingError

impl RefUnwindSafe for RoundingError

impl Send for RoundingError

impl Sync for RoundingError

impl Unpin for RoundingError

impl UnsafeUnpin for RoundingError

impl UnwindSafe for RoundingError

Blanket Implementations

impl<T> Any for RoundingError where T: 'static + ?Sized,

fn type_id(&self) -> TypeId

impl<T> Borrow<T> for RoundingError where T: ?Sized,

fn borrow(&self) -> &T

impl<T> BorrowMut<T> for RoundingError where T: ?Sized,

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

impl<T> CloneToUninit for RoundingError where T: Clone,

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

impl<T> From<T> for RoundingError

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> ToOwned for RoundingError where T: Clone,

type Owned = T;
fn to_owned(&self) -> T
fn clone_into(&self, target: &mut T)

impl<T> ToString for RoundingError where T: Display + ?Sized,

fn to_string(&self) -> String

impl<T, U> Into<U> for RoundingError where U: From<T>,

fn into(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<U> for RoundingError where U: Into<T>,

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

impl<T, U> TryInto<U> for RoundingError where U: TryFrom<T>,

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