Timestamp

Struct Timestamp 

Source
pub struct Timestamp { /* private fields */ }
Expand description

A point in time, measured in microseconds since the Unix epoch.

Implementations§

Source§

impl Timestamp

Source

pub const UNIX_EPOCH: Timestamp

Source

pub fn now() -> Timestamp

Source

pub fn to_micros_since_unix_epoch(self) -> i64

Get the number of microseconds self is offset from Self::UNIX_EPOCH.

A positive value means a time after the Unix epoch, and a negative value means a time before.

Source

pub fn from_micros_since_unix_epoch(micros: i64) -> Timestamp

Construct a Timestamp which is micros microseconds offset from Self::UNIX_EPOCH.

A positive value means a time after the Unix epoch, and a negative value means a time before.

Source

pub fn from_time_duration_since_unix_epoch( time_duration: TimeDuration, ) -> Timestamp

Source

pub fn to_time_duration_since_unix_epoch(self) -> TimeDuration

Source

pub fn to_duration_since_unix_epoch(self) -> Result<Duration, Duration>

Returns Err(duration_before_unix_epoch) if self is before Self::UNIX_EPOCH.

Source

pub fn from_duration_since_unix_epoch(duration: Duration) -> Timestamp

Return a Timestamp which is Timestamp::UNIX_EPOCH plus duration.

Panics if duration.as_micros overflows an i64

Source

pub fn to_system_time(self) -> SystemTime

Convert self into a SystemTime which refers to approximately the same point in time.

This conversion may lose precision, as SystemTime’s prevision varies depending on platform. E.g. Unix targets have microsecond precision, but Windows only 100-microsecond precision.

This conversion may panic if self is out of bounds for SystemTime. We are not aware of any platforms for which SystemTime offers a smaller range than Timestamp, but such a platform may exist.

Source

pub fn from_system_time(system_time: SystemTime) -> Timestamp

Convert a SystemTime into a Timestamp which refers to approximately the same point in time.

This conversion may panic if system_time is out of bounds for Duration. SystemTime’s range is larger than Timestamp on both Unix and Windows targets, so times in the far past or far future may panic. Timestamp’s range is approximately 292 years before and after the Unix epoch.

Source

pub fn duration_since(self, earlier: Timestamp) -> Option<Duration>

Returns the Duration delta between self and earlier, if earlier predates self.

Returns None if earlier is strictly greater than self, or if the difference between earlier and self overflows an i64.

Source

pub fn time_duration_since(self, earlier: Timestamp) -> Option<TimeDuration>

Returns the TimeDuration delta between self and earlier.

The result may be negative if earlier is actually later than self.

Returns None if the subtraction overflows or underflows i64 microseconds.

Source

pub fn parse_from_rfc3339(str: &str) -> Result<Timestamp, Error>

Parses an RFC 3339 formatted timestamp string

Source

pub fn checked_add(&self, duration: TimeDuration) -> Option<Timestamp>

Returns Some(t) where t is the time self + duration if t can be represented as a Timestamp, i.e. a 64-bit signed number of microseconds before or after the Unix epoch.

Source

pub fn checked_sub(&self, duration: TimeDuration) -> Option<Timestamp>

Returns Some(t) where t is the time self - duration if t can be represented as a Timestamp, i.e. a 64-bit signed number of microseconds before or after the Unix epoch.

Source

pub fn checked_add_duration(&self, duration: Duration) -> Option<Timestamp>

Returns Some(self + duration), or None if that value would be out-of-bounds for Timestamp.

Converts duration into a TimeDuration before the arithmetic. Depending on the target platform’s representation of Duration, this may lose precision.

Source

pub fn checked_sub_duration(&self, duration: Duration) -> Option<Timestamp>

Returns Some(self - duration), or None if that value would be out-of-bounds for Timestamp.

Converts duration into a TimeDuration before the arithmetic. Depending on the target platform’s representation of Duration, this may lose precision.

Source

pub fn to_chrono_date_time(&self) -> Result<DateTime<Utc>, Error>

Source

pub fn to_rfc3339(&self) -> Result<String, Error>

Returns an RFC 3339 and ISO 8601 date and time string such as 1996-12-19T16:39:57-08:00.

Trait Implementations§

Source§

impl Add<Duration> for Timestamp

Source§

type Output = Timestamp

The resulting type after applying the + operator.
Source§

fn add(self, other: Duration) -> <Timestamp as Add<Duration>>::Output

Performs the + operation. Read more
Source§

impl Add<TimeDuration> for Timestamp

Source§

type Output = Timestamp

The resulting type after applying the + operator.
Source§

fn add(self, other: TimeDuration) -> <Timestamp as Add<TimeDuration>>::Output

Performs the + operation. Read more
Source§

impl AddAssign<Duration> for Timestamp

Source§

fn add_assign(&mut self, other: Duration)

Performs the += operation. Read more
Source§

impl AddAssign<TimeDuration> for Timestamp

Source§

fn add_assign(&mut self, other: TimeDuration)

Performs the += operation. Read more
Source§

impl Clone for Timestamp

Source§

fn clone(&self) -> Timestamp

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Timestamp

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Timestamp

Source§

fn deserialize<D>( deserializer: D, ) -> Result<Timestamp, <D as Deserializer<'de>>::Error>
where D: Deserializer<'de>,

Deserialize this value from the given deserializer.
Source§

impl Display for Timestamp

Source§

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

Formats the value using the given formatter. Read more
Source§

impl From<SystemTime> for Timestamp

Source§

fn from(system_time: SystemTime) -> Timestamp

Converts to this type from the input type.
Source§

impl From<Timestamp> for AlgebraicValue

Source§

fn from(value: Timestamp) -> AlgebraicValue

Converts to this type from the input type.
Source§

impl From<Timestamp> for ScheduleAt

Source§

fn from(value: Timestamp) -> Self

Converts to this type from the input type.
Source§

impl GroundSpacetimeType for Timestamp

Source§

fn get_type() -> AlgebraicType

Returns the AlgebraicType representation of Self.
Source§

impl Hash for Timestamp

Source§

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

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for Timestamp

Source§

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

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for Timestamp

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for Timestamp

Source§

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

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Serialize for Timestamp

Source§

fn serialize<S>( &self, __serializer: S, ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
where S: Serializer,

Serialize self in the data format of S using the provided serializer.
Source§

impl SpacetimeType for Timestamp

Source§

fn make_type<S>(_ts: &mut S) -> AlgebraicType

Returns an AlgebraicType representing the type for Self in SATS and in the typing context in typespace. This is used by the automatic type registration system in Rust modules. Read more
Source§

impl Sub<Duration> for Timestamp

Source§

type Output = Timestamp

The resulting type after applying the - operator.
Source§

fn sub(self, other: Duration) -> <Timestamp as Sub<Duration>>::Output

Performs the - operation. Read more
Source§

impl Sub<TimeDuration> for Timestamp

Source§

type Output = Timestamp

The resulting type after applying the - operator.
Source§

fn sub(self, other: TimeDuration) -> <Timestamp as Sub<TimeDuration>>::Output

Performs the - operation. Read more
Source§

impl SubAssign<Duration> for Timestamp

Source§

fn sub_assign(&mut self, rhs: Duration)

Performs the -= operation. Read more
Source§

impl SubAssign<TimeDuration> for Timestamp

Source§

fn sub_assign(&mut self, rhs: TimeDuration)

Performs the -= operation. Read more
Source§

impl Copy for Timestamp

Source§

impl Eq for Timestamp

Source§

impl StructuralPartialEq for Timestamp

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> CloneToUninit for T
where T: Clone,

Source§

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

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> Satn for T
where T: Serialize + ?Sized,

Source§

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

Formats the value using the SATN data format into the formatter f.
Source§

fn fmt_psql( &self, f: &mut Formatter<'_>, ty: &PsqlType<'_>, ) -> Result<(), Error>

Formats the value using the postgres SATN(PsqlFormatter { f }, /* PsqlType */) formatter f.
Source§

fn to_satn(&self) -> String

Formats the value using the SATN data format into the returned String.
Source§

fn to_satn_pretty(&self) -> String

Pretty prints the value using the SATN data format into the returned String.
Source§

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

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,