pub struct ZonedArithmetic { /* private fields */ }
Expand description
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:
From<Span> for ZonedArithmetic
adds (or subtracts) the given span to the receiver timestamp.From<SignedDuration> for ZonedArithmetic
adds (or subtracts) the given signed duration to the receiver timestamp.From<std::time::Duration> for ZonedArithmetic
adds (or subtracts) the given unsigned duration to the receiver timestamp.
§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()?,
);
Trait Implementations§
Source§impl Clone for ZonedArithmetic
impl Clone for ZonedArithmetic
Source§fn clone(&self) -> ZonedArithmetic
fn clone(&self) -> ZonedArithmetic
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for ZonedArithmetic
impl Debug for ZonedArithmetic
Source§impl<'a> From<&'a Duration> for ZonedArithmetic
impl<'a> From<&'a Duration> for ZonedArithmetic
Source§fn from(udur: &'a Duration) -> ZonedArithmetic
fn from(udur: &'a Duration) -> ZonedArithmetic
Converts to this type from the input type.
Source§impl<'a> From<&'a SignedDuration> for ZonedArithmetic
impl<'a> From<&'a SignedDuration> for ZonedArithmetic
Source§fn from(sdur: &'a SignedDuration) -> ZonedArithmetic
fn from(sdur: &'a SignedDuration) -> ZonedArithmetic
Converts to this type from the input type.
Source§impl<'a> From<&'a Span> for ZonedArithmetic
impl<'a> From<&'a Span> for ZonedArithmetic
Source§fn from(span: &'a Span) -> ZonedArithmetic
fn from(span: &'a Span) -> ZonedArithmetic
Converts to this type from the input type.
Source§impl From<Duration> for ZonedArithmetic
impl From<Duration> for ZonedArithmetic
Source§fn from(udur: Duration) -> ZonedArithmetic
fn from(udur: Duration) -> ZonedArithmetic
Converts to this type from the input type.
Source§impl From<SignedDuration> for ZonedArithmetic
impl From<SignedDuration> for ZonedArithmetic
Source§fn from(sdur: SignedDuration) -> ZonedArithmetic
fn from(sdur: SignedDuration) -> ZonedArithmetic
Converts to this type from the input type.
Source§impl From<Span> for ZonedArithmetic
impl From<Span> for ZonedArithmetic
Source§fn from(span: Span) -> ZonedArithmetic
fn from(span: Span) -> ZonedArithmetic
Converts to this type from the input type.
impl Copy for 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 UnwindSafe for ZonedArithmetic
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more