Struct Timestamp

pub struct Timestamp { /* private fields */ }

The representation for a timestamp used by the TZif implementation.

We don't use Timestamp from the root of this crate because TZif data doesn't require nanosecond resolution. Instead, this representation uses only second resolution. This makes for a more compact sequence of transitions, which means more data fits into cache and thus faster binary search.

Implementations

impl Timestamp

const MIN: Timestamp = _;

The minimum timestamp value.

const MAX: Timestamp = _;

The maximum timestamp value.

const UNIX_EPOCH: Timestamp = _;

The zero value for a timestamp, which also corresponds to the Unix epoch (1970-01-01T00:00:00Z).

const fn new(ts: Timestamp) -> Timestamp

Creates a new TZif timestamp from jiff-core's standard timestamp type.

Note that this completely ignores any subsecond component of the provided timestamp.

const fn from_second(second: i64) -> Result<Timestamp, RangeError>

Creates a new Timestamp from a Unix timestamp integer value.

This returns an error if the value is not in the legal bounds for this type.

const fn as_second(self) -> i64

Returns the second value of this timestamp.

It is the number of seconds since the Unix epoch (1970-01-01T00:00:00Z). Timestamps prior to the Unix epoch are negative. Timestamps are the Unix epoch are 0.

const fn to_datetime(self, offset: Offset) -> DateTime

Converts this timestamp to a civil datetime for the offset given.

const fn to_standard_timestamp(self) -> Timestamp

Converts this timestamp back to the "standard" timestamp.

Note that the timestamp returned here always has its nanosecond component set to 0.

Trait Implementations

impl Clone for Timestamp

fn clone(&self) -> Timestamp

impl Copy for Timestamp

impl Debug for Timestamp

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

impl Eq for Timestamp

impl Hash for Timestamp

fn hash<__H: Hasher>(&self, state: &mut __H)

impl Ord for Timestamp

fn cmp(&self, other: &Timestamp) -> Ordering

impl PartialEq for Timestamp

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

impl PartialOrd for Timestamp

fn partial_cmp(&self, other: &Timestamp) -> Option<Ordering>

impl StructuralPartialEq for Timestamp

Auto Trait Implementations

impl Freeze for Timestamp

impl RefUnwindSafe for Timestamp

impl Send for Timestamp

impl Sync for Timestamp

impl Unpin for Timestamp

impl UnsafeUnpin for Timestamp

impl UnwindSafe for Timestamp

Blanket Implementations

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

fn type_id(&self) -> TypeId

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

fn borrow(&self) -> &T

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

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

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

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

impl<T> From<T> for Timestamp

fn from(t: T) -> T

Returns the argument unchanged.

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

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

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

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