Struct TimeArithmetic

struct TimeArithmetic { ... }

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

Implementations

impl Clone for TimeArithmetic

fn clone(self: &Self) -> TimeArithmetic

impl Copy for TimeArithmetic

impl Debug for TimeArithmetic

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

impl Freeze for TimeArithmetic

impl From for TimeArithmetic

fn from(span: Span) -> TimeArithmetic

impl From for TimeArithmetic

fn from(sdur: SignedDuration) -> TimeArithmetic

impl From for TimeArithmetic

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

impl<'a> From for TimeArithmetic

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

impl<'a> From for TimeArithmetic

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

impl<'a> From for TimeArithmetic

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

impl<T> Any for TimeArithmetic

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for TimeArithmetic

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

impl<T> BorrowMut for TimeArithmetic

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

impl<T> CloneToUninit for TimeArithmetic

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

impl<T> From for TimeArithmetic

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> ToOwned for TimeArithmetic

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

impl<T, U> Into for TimeArithmetic

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 TimeArithmetic

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

impl<T, U> TryInto for TimeArithmetic

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