Struct ZonedArithmetic

pub struct ZonedArithmetic { /* 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 ZonedArithmetic

fn clone(&self) -> Self

impl Copy for ZonedArithmetic

impl Debug for ZonedArithmetic

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

impl From<Duration> for ZonedArithmetic

fn from(udur: UnsignedDuration) -> ZonedArithmetic

impl From<SignedDuration> for ZonedArithmetic

fn from(sdur: SignedDuration) -> ZonedArithmetic

impl From<Span> for ZonedArithmetic

fn from(span: Span) -> ZonedArithmetic

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

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

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

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

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

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

Auto Trait Implementations

impl Freeze for ZonedArithmetic

impl RefUnwindSafe for ZonedArithmetic

impl Send for ZonedArithmetic

impl Sync for ZonedArithmetic

impl Unpin for ZonedArithmetic

impl UnsafeUnpin for ZonedArithmetic

impl UnwindSafe for ZonedArithmetic

Blanket Implementations

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

fn type_id(&self) -> TypeId

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

fn borrow(&self) -> &T

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

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

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

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

impl<T> From<T> for ZonedArithmetic

fn from(t: T) -> T

Returns the argument unchanged.

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

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

impl<T, U> Into<U> for ZonedArithmetic 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 ZonedArithmetic where U: Into<T>,

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

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

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