Struct TimeArithmetic

pub struct TimeArithmetic { /* private fields */ }

Options for Time::checked_add and Time::checked_sub.

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

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

Example

use std::time::Duration;

use jiff::{civil::time, SignedDuration, ToSpan};

let t = time(0, 0, 0, 0);
assert_eq!(t.checked_add(2.hours())?, time(2, 0, 0, 0));
assert_eq!(t.checked_add(SignedDuration::from_hours(2))?, time(2, 0, 0, 0));
assert_eq!(t.checked_add(Duration::from_secs(2 * 60 * 60))?, time(2, 0, 0, 0));

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

Trait Implementations

impl Clone for TimeArithmetic

fn clone(&self) -> Self

impl Copy for TimeArithmetic

impl Debug for TimeArithmetic

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

impl From<Duration> for TimeArithmetic

fn from(udur: UnsignedDuration) -> TimeArithmetic

impl From<SignedDuration> for TimeArithmetic

fn from(sdur: SignedDuration) -> TimeArithmetic

impl From<Span> for TimeArithmetic

fn from(span: Span) -> TimeArithmetic

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

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

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

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

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

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

Auto Trait Implementations

impl Freeze for TimeArithmetic

impl RefUnwindSafe for TimeArithmetic

impl Send for TimeArithmetic

impl Sync for TimeArithmetic

impl Unpin for TimeArithmetic

impl UnsafeUnpin for TimeArithmetic

impl UnwindSafe for TimeArithmetic

Blanket Implementations

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

fn type_id(&self) -> TypeId

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

fn borrow(&self) -> &T

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

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

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

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

impl<T> From<T> for TimeArithmetic

fn from(t: T) -> T

Returns the argument unchanged.

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

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

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

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

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

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