Struct TimestampArithmetic

pub struct TimestampArithmetic { /* private fields */ }

Options for Timestamp::checked_add and Timestamp::checked_sub.

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

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

Example

use std::time::Duration;

use jiff::{SignedDuration, Timestamp, ToSpan};

let ts: Timestamp = "2024-02-28T00:00:00Z".parse()?;
assert_eq!(
    ts.checked_add(48.hours())?,
    "2024-03-01T00:00:00Z".parse()?,
);
assert_eq!(
    ts.checked_add(SignedDuration::from_hours(48))?,
    "2024-03-01T00:00:00Z".parse()?,
);
assert_eq!(
    ts.checked_add(Duration::from_secs(48 * 60 * 60))?,
    "2024-03-01T00:00:00Z".parse()?,
);

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

Trait Implementations

impl Clone for TimestampArithmetic

fn clone(&self) -> Self

impl Copy for TimestampArithmetic

impl Debug for TimestampArithmetic

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

impl From<Duration> for TimestampArithmetic

fn from(udur: UnsignedDuration) -> TimestampArithmetic

impl From<SignedDuration> for TimestampArithmetic

fn from(sdur: SignedDuration) -> TimestampArithmetic

impl From<Span> for TimestampArithmetic

fn from(span: Span) -> TimestampArithmetic

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

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

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

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

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

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

Auto Trait Implementations

impl Freeze for TimestampArithmetic

impl RefUnwindSafe for TimestampArithmetic

impl Send for TimestampArithmetic

impl Sync for TimestampArithmetic

impl Unpin for TimestampArithmetic

impl UnsafeUnpin for TimestampArithmetic

impl UnwindSafe for TimestampArithmetic

Blanket Implementations

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

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

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

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

impl<T> From<T> for TimestampArithmetic

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

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

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

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