Skip to main content

DeltaSeconds

Struct DeltaSeconds 

Source
pub struct DeltaSeconds(/* private fields */);
Expand description

The range of seconds for the possible differences between any two pairs of (timestamp, offset).

All of our span types (except for years and months, since they have variable length even in civil datetimes) are defined in terms of this constant. The way it’s defined is a little odd, so let’s break it down.

Firstly, a span of seconds should be able to represent at least the complete span supported by Timestamp. Thus, it’s based off of UnixSeconds::LEN. That is, a span should be able to represent the value UnixSeconds::MAX - UnixSeconds::MIN.

Secondly, a span should also be able to account for any amount of possible time that a time zone offset might add or subtract to an Timestamp. This also means it can account for any difference between two civil::DateTime values.

Thirdly, we would like our span to be divisible by SECONDS_PER_CIVIL_DAY. This isn’t strictly required, but it makes defining boundaries a little smoother. If it weren’t divisible, then the lower bounds on some types would need to be adjusted by one.

Note that neither the existence of this constant nor defining our spans based on it impacts the correctness of doing arithmetic on zoned instants. Arithmetic on zoned instants still uses “civil” spans, but the length of time for some units (like a day) might vary. The arithmetic for zoned instants accounts for this explicitly. But it still must obey the limits set here.

Implementations§

Source§

impl DeltaSeconds

Source

pub const MIN: i64 = <DeltaSeconds as Bounds>::MIN

Source

pub const MAX: i64 = <DeltaSeconds as Bounds>::MAX

Source

pub const LEN: i128

Source

pub const fn error() -> BoundsError

Source

pub fn check(n: impl Into<i64>) -> Result<i64, BoundsError>

Source

pub const fn checkc(n: i64) -> Result<i64, BoundsError>

Source

pub const fn checked_add(n1: i64, n2: i64) -> Result<i64, BoundsError>

Source

pub fn checked_mul(n1: i64, n2: i64) -> Result<i64, BoundsError>

Trait Implementations§

Source§

impl Bounds for DeltaSeconds

Source§

const WHAT: &'static str = "seconds"

A short human readable description of the values represented by these bounds. This is used in error messages.
Source§

const MIN: Self::Primitive

The minimum boundary value.
Source§

const MAX: Self::Primitive

The maximum boundary value.
Source§

type Primitive = i64

The primitive integer representation for this boundary type. Read more
Source§

type Error = BoundsError

The error type returned when a value is considered out of range for this particular implementation. Read more
Source§

fn error() -> BoundsError

Create an error when a value is outside the bounds for this type.
Source§

fn check(n: impl Into<i64>) -> Result<Self::Primitive, Self::Error>

Converts the 64-bit integer provided into the primitive representation of these bounds. Read more
Source§

fn check_self(n: Self::Primitive) -> Result<Self::Primitive, Self::Error>

Checks whether the given integer, in the same primitive representation as this boundary type, is in bounds. Read more
Source§

fn checked_add( n1: Self::Primitive, n2: Self::Primitive, ) -> Result<Self::Primitive, Self::Error>

Performs checked addition using this boundary type’s primitive representation. Read more
Source§

fn checked_mul( n1: Self::Primitive, n2: Self::Primitive, ) -> Result<Self::Primitive, Self::Error>

Performs checked multiplication using this boundary type’s primitive representation. Read more
Source§

impl Eq for DeltaSeconds

Source§

impl PartialEq for DeltaSeconds

Source§

fn eq(&self, other: &DeltaSeconds) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for DeltaSeconds

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

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

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.