Skip to main content

UnixEpochSeconds

Struct UnixEpochSeconds 

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

The supported range of seconds for the difference between any two values of UnixEpochDays.

This range should correspond to the first second of Year::MIN (with a minimal offset) up through (and including) the last second of Year::MAX (with a maximal offset). Actually computing that is non-trivial, however, it can be computed easily enough using Unix programs like date:

$ TZ=0 date -d 'Mon Jan  1 12:00:00 AM  -9999' +'%s'
date: invalid date ‘Mon Jan  1 12:00:00 AM  -9999’
$ TZ=0 date -d 'Fri Dec 31 23:59:59  9999' +'%s'
253402300799

Well, almost easily enough. date apparently doesn’t support negative years. But it does support negative timestamps:

$ TZ=0 date -d '@-377705116800'
Mon Jan  1 12:00:00 AM  -9999
$ TZ=0 date -d '@253402300799'
Fri Dec 31 11:59:59 PM  9999

With that said, we actually end up restricting the range a bit more than what’s above. Namely, what’s above is what we support for civil datetimes. Because of time zones, we need to choose whether all Timestamp values can be infallibly converted to civil::DateTime values, or whether all civil::DateTime values can be infallibly converted to Timestamp values. Jiff choses the former because getting a civil datetime is important for formatting. If Jiff didn’t choose the former, there would be some timestamps that could not be formatted. Thus, we make room by shrinking the range of allowed instants by precisely the maximum supported time zone offset.

Implementations§

Source§

impl UnixEpochSeconds

Source

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

Source

pub const MAX: i64 = <UnixEpochSeconds 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 UnixEpochSeconds

Source§

const WHAT: &'static str = "Unix timestamp 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 UnixEpochSeconds

Source§

impl PartialEq for UnixEpochSeconds

Source§

fn eq(&self, other: &UnixEpochSeconds) -> 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 UnixEpochSeconds

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.