Struct UnixEpochSeconds

pub struct UnixEpochSeconds(/* private field */);

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

impl UnixEpochSeconds

const MIN: i64 = <UnixEpochSeconds as Bounds>::MIN;
const MAX: i64 = <UnixEpochSeconds as Bounds>::MAX;
const LEN: i128 = _;
const fn error() -> BoundsError
fn check(n: impl Into<i64>) -> Result<i64, BoundsError>
const fn checkc(n: i64) -> Result<i64, BoundsError>
const fn checked_add(n1: i64, n2: i64) -> Result<i64, BoundsError>
fn checked_mul(n1: i64, n2: i64) -> Result<i64, BoundsError>

Trait Implementations

impl Bounds for UnixEpochSeconds

const WHAT: &'static str = "Unix timestamp seconds";
const MIN: Self::Primitive = _;
const MAX: Self::Primitive = _;
type Primitive = i64;
type Error = BoundsError;
fn error() -> BoundsError

impl Eq for UnixEpochSeconds

impl PartialEq for UnixEpochSeconds

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

impl StructuralPartialEq for UnixEpochSeconds

Auto Trait Implementations

impl Freeze for UnixEpochSeconds

impl RefUnwindSafe for UnixEpochSeconds

impl Send for UnixEpochSeconds

impl Sync for UnixEpochSeconds

impl Unpin for UnixEpochSeconds

impl UnsafeUnpin for UnixEpochSeconds

impl UnwindSafe for UnixEpochSeconds

Blanket Implementations

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

fn type_id(&self) -> TypeId

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

fn borrow(&self) -> &T

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

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

impl<T> From<T> for UnixEpochSeconds

fn from(t: T) -> T

Returns the argument unchanged.

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

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

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

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