Struct DateArithmetic

pub struct DateArithmetic { /* private fields */ }

Options for Date::checked_add and Date::checked_sub.

This type provides a way to ergonomically add one of a few different duration types to a Date.

The main way to construct values of this type is with its From trait implementations:

Example

use std::time::Duration;

use jiff::{civil::date, SignedDuration, ToSpan};

let d = date(2024, 2, 29);
assert_eq!(d.checked_add(1.year())?, date(2025, 2, 28));
assert_eq!(d.checked_add(SignedDuration::from_hours(24))?, date(2024, 3, 1));
assert_eq!(d.checked_add(Duration::from_secs(24 * 60 * 60))?, date(2024, 3, 1));

# Ok::<(), Box<dyn std::error::Error>>(())

Trait Implementations

impl Clone for DateArithmetic

fn clone(&self) -> Self

impl Copy for DateArithmetic

impl Debug for DateArithmetic

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

impl From<Duration> for DateArithmetic

fn from(udur: UnsignedDuration) -> DateArithmetic

impl From<SignedDuration> for DateArithmetic

fn from(sdur: SignedDuration) -> DateArithmetic

impl From<Span> for DateArithmetic

fn from(span: Span) -> DateArithmetic

impl<'a> From<&'a Duration> for DateArithmetic

fn from(udur: &'a UnsignedDuration) -> DateArithmetic

impl<'a> From<&'a SignedDuration> for DateArithmetic

fn from(sdur: &'a SignedDuration) -> DateArithmetic

impl<'a> From<&'a Span> for DateArithmetic

fn from(span: &'a Span) -> DateArithmetic

Auto Trait Implementations

impl Freeze for DateArithmetic

impl RefUnwindSafe for DateArithmetic

impl Send for DateArithmetic

impl Sync for DateArithmetic

impl Unpin for DateArithmetic

impl UnsafeUnpin for DateArithmetic

impl UnwindSafe for DateArithmetic

Blanket Implementations

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

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

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

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

impl<T> From<T> for DateArithmetic

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

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

impl<T, U> TryFrom<U> for DateArithmetic where U: Into<T>,

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