pub struct Timestamp { /* private fields */ }Expand description
A point in time, measured in microseconds since the Unix epoch.
Implementations§
Source§impl Timestamp
impl Timestamp
pub const UNIX_EPOCH: Timestamp
pub fn now() -> Timestamp
Sourcepub fn to_micros_since_unix_epoch(self) -> i64
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.
Sourcepub fn from_micros_since_unix_epoch(micros: i64) -> Timestamp
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.
pub fn from_time_duration_since_unix_epoch( time_duration: TimeDuration, ) -> Timestamp
pub fn to_time_duration_since_unix_epoch(self) -> TimeDuration
Sourcepub fn to_duration_since_unix_epoch(self) -> Result<Duration, Duration>
pub fn to_duration_since_unix_epoch(self) -> Result<Duration, Duration>
Returns Err(duration_before_unix_epoch) if self is before Self::UNIX_EPOCH.
Sourcepub fn from_duration_since_unix_epoch(duration: Duration) -> Timestamp
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
Sourcepub fn to_system_time(self) -> SystemTime
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.
Sourcepub fn from_system_time(system_time: SystemTime) -> Timestamp
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.
Sourcepub fn duration_since(self, earlier: Timestamp) -> Option<Duration>
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.
Sourcepub fn time_duration_since(self, earlier: Timestamp) -> Option<TimeDuration>
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.
Sourcepub fn parse_from_rfc3339(str: &str) -> Result<Timestamp, Error>
pub fn parse_from_rfc3339(str: &str) -> Result<Timestamp, Error>
Parses an RFC 3339 formatted timestamp string
Sourcepub fn checked_add(&self, duration: TimeDuration) -> Option<Timestamp>
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.
Sourcepub fn checked_sub(&self, duration: TimeDuration) -> Option<Timestamp>
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.
Sourcepub fn checked_add_duration(&self, duration: Duration) -> Option<Timestamp>
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.
Sourcepub fn checked_sub_duration(&self, duration: Duration) -> Option<Timestamp>
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.
pub fn to_chrono_date_time(&self) -> Result<DateTime<Utc>, Error>
Sourcepub fn to_rfc3339(&self) -> Result<String, Error>
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<TimeDuration> for Timestamp
impl Add<TimeDuration> for Timestamp
Source§impl AddAssign<Duration> for Timestamp
impl AddAssign<Duration> for Timestamp
Source§fn add_assign(&mut self, other: Duration)
fn add_assign(&mut self, other: Duration)
+= operation. Read moreSource§impl AddAssign<TimeDuration> for Timestamp
impl AddAssign<TimeDuration> for Timestamp
Source§fn add_assign(&mut self, other: TimeDuration)
fn add_assign(&mut self, other: TimeDuration)
+= operation. Read moreSource§impl<'de> Deserialize<'de> for Timestamp
impl<'de> Deserialize<'de> for Timestamp
Source§fn deserialize<D>(
deserializer: D,
) -> Result<Timestamp, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<Timestamp, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
deserializer.Source§impl From<SystemTime> for Timestamp
impl From<SystemTime> for Timestamp
Source§fn from(system_time: SystemTime) -> Timestamp
fn from(system_time: SystemTime) -> Timestamp
Source§impl From<Timestamp> for AlgebraicValue
impl From<Timestamp> for AlgebraicValue
Source§fn from(value: Timestamp) -> AlgebraicValue
fn from(value: Timestamp) -> AlgebraicValue
Source§impl From<Timestamp> for ScheduleAt
impl From<Timestamp> for ScheduleAt
Source§impl GroundSpacetimeType for Timestamp
impl GroundSpacetimeType for Timestamp
Source§fn get_type() -> AlgebraicType
fn get_type() -> AlgebraicType
AlgebraicType representation of Self.Source§impl Ord for Timestamp
impl Ord for Timestamp
Source§impl PartialOrd for Timestamp
impl PartialOrd for Timestamp
Source§impl Serialize for Timestamp
impl Serialize for Timestamp
Source§fn serialize<S>(
&self,
__serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
__serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
self in the data format of S using the provided serializer.Source§impl SpacetimeType for Timestamp
impl SpacetimeType for Timestamp
Source§fn make_type<S>(_ts: &mut S) -> AlgebraicTypewhere
S: TypespaceBuilder,
fn make_type<S>(_ts: &mut S) -> AlgebraicTypewhere
S: TypespaceBuilder,
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 moreSource§impl Sub<TimeDuration> for Timestamp
impl Sub<TimeDuration> for Timestamp
Source§impl SubAssign<Duration> for Timestamp
impl SubAssign<Duration> for Timestamp
Source§fn sub_assign(&mut self, rhs: Duration)
fn sub_assign(&mut self, rhs: Duration)
-= operation. Read moreSource§impl SubAssign<TimeDuration> for Timestamp
impl SubAssign<TimeDuration> for Timestamp
Source§fn sub_assign(&mut self, rhs: TimeDuration)
fn sub_assign(&mut self, rhs: TimeDuration)
-= operation. Read moreimpl Copy for Timestamp
impl Eq for Timestamp
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 UnwindSafe for Timestamp
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<T> Satn for T
impl<T> Satn for T
Source§fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>
f.Source§fn fmt_psql(
&self,
f: &mut Formatter<'_>,
ty: &PsqlType<'_>,
) -> Result<(), Error>
fn fmt_psql( &self, f: &mut Formatter<'_>, ty: &PsqlType<'_>, ) -> Result<(), Error>
f.Source§fn to_satn(&self) -> String
fn to_satn(&self) -> String
String.Source§fn to_satn_pretty(&self) -> String
fn to_satn_pretty(&self) -> String
String.