Struct TimestampArithmetic

struct TimestampArithmetic { ... }

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>>(())

Implementations

impl Clone for TimestampArithmetic

fn clone(self: &Self) -> TimestampArithmetic

impl Copy for TimestampArithmetic

impl Debug for TimestampArithmetic

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

impl Freeze for TimestampArithmetic

impl From for TimestampArithmetic

fn from(sdur: SignedDuration) -> TimestampArithmetic

impl From for TimestampArithmetic

fn from(span: Span) -> TimestampArithmetic

impl From for TimestampArithmetic

fn from(udur: UnsignedDuration) -> 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

impl<'a> From for TimestampArithmetic

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

impl<'a> From for TimestampArithmetic

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

impl<'a> From for TimestampArithmetic

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

impl<T> Any for TimestampArithmetic

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for TimestampArithmetic

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

impl<T> BorrowMut for TimestampArithmetic

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

impl<T> CloneToUninit for TimestampArithmetic

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

impl<T> From for TimestampArithmetic

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> ToOwned for TimestampArithmetic

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

impl<T, U> Into for TimestampArithmetic

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 TimestampArithmetic

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

impl<T, U> TryInto for TimestampArithmetic

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