pub struct ZonedDateTimeArithmetic { /* 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 ZonedDateTimeArithmeticadds (or subtracts) the given span to the receiver timestamp.From<SignedDuration> for ZonedDateTimeArithmeticadds (or subtracts) the given signed duration to the receiver timestamp.From<std::time::Duration> for ZonedDateTimeArithmeticadds (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 ZonedDateTimeArithmetic
impl Clone for ZonedDateTimeArithmetic
impl Copy for ZonedDateTimeArithmetic
Source§impl Debug for ZonedDateTimeArithmetic
impl Debug for ZonedDateTimeArithmetic
Source§impl<'a> From<&'a Duration> for ZonedDateTimeArithmetic
impl<'a> From<&'a Duration> for ZonedDateTimeArithmetic
Source§fn from(udur: &'a UnsignedDuration) -> ZonedDateTimeArithmetic
fn from(udur: &'a UnsignedDuration) -> ZonedDateTimeArithmetic
Converts to this type from the input type.
Source§impl<'a> From<&'a SignedDuration> for ZonedDateTimeArithmetic
impl<'a> From<&'a SignedDuration> for ZonedDateTimeArithmetic
Source§fn from(sdur: &'a SignedDuration) -> ZonedDateTimeArithmetic
fn from(sdur: &'a SignedDuration) -> ZonedDateTimeArithmetic
Converts to this type from the input type.
Source§impl<'a> From<&'a Span> for ZonedDateTimeArithmetic
impl<'a> From<&'a Span> for ZonedDateTimeArithmetic
Source§fn from(span: &'a Span) -> ZonedDateTimeArithmetic
fn from(span: &'a Span) -> ZonedDateTimeArithmetic
Converts to this type from the input type.
Source§impl From<Duration> for ZonedDateTimeArithmetic
impl From<Duration> for ZonedDateTimeArithmetic
Source§fn from(udur: UnsignedDuration) -> ZonedDateTimeArithmetic
fn from(udur: UnsignedDuration) -> ZonedDateTimeArithmetic
Converts to this type from the input type.
Source§impl From<SignedDuration> for ZonedDateTimeArithmetic
impl From<SignedDuration> for ZonedDateTimeArithmetic
Source§fn from(sdur: SignedDuration) -> ZonedDateTimeArithmetic
fn from(sdur: SignedDuration) -> ZonedDateTimeArithmetic
Converts to this type from the input type.
Source§impl From<Span> for ZonedDateTimeArithmetic
impl From<Span> for ZonedDateTimeArithmetic
Source§fn from(span: Span) -> ZonedDateTimeArithmetic
fn from(span: Span) -> ZonedDateTimeArithmetic
Converts to this type from the input type.
Auto Trait Implementations§
impl Forget for ZonedDateTimeArithmetic
impl Freeze for ZonedDateTimeArithmetic
impl Move for ZonedDateTimeArithmetic
impl RefUnwindSafe for ZonedDateTimeArithmetic
impl Send for ZonedDateTimeArithmetic
impl Sync for ZonedDateTimeArithmetic
impl Unpin for ZonedDateTimeArithmetic
impl UnsafeUnpin for ZonedDateTimeArithmetic
impl UnwindSafe for ZonedDateTimeArithmetic
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