pub struct Timestamp(/* private fields */);
Expand description
A point in time in nanosecond precision.
This type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.
§Examples
let ts = Timestamp::from_nanos(1_000_000_202);
assert_eq!(ts.nanos(), 1_000_000_202);
assert_eq!(ts.seconds(), 1);
assert_eq!(ts.subsec_nanos(), 202);
let ts = ts.plus_seconds(2);
assert_eq!(ts.nanos(), 3_000_000_202);
assert_eq!(ts.seconds(), 3);
assert_eq!(ts.subsec_nanos(), 202);
Implementations§
Source§impl Timestamp
impl Timestamp
Sourcepub const fn from_nanos(nanos_since_epoch: u64) -> Self
pub const fn from_nanos(nanos_since_epoch: u64) -> Self
Creates a timestamp from nanoseconds since epoch
Sourcepub const fn from_seconds(seconds_since_epoch: u64) -> Self
pub const fn from_seconds(seconds_since_epoch: u64) -> Self
Creates a timestamp from seconds since epoch
Sourcepub const fn plus_days(&self, addition: u64) -> Timestamp
pub const fn plus_days(&self, addition: u64) -> Timestamp
Adds the given amount of days to the timestamp and returns the result. The original value remains unchanged.
Panics if the result exceeds the value range of Timestamp
.
Sourcepub const fn plus_hours(&self, addition: u64) -> Timestamp
pub const fn plus_hours(&self, addition: u64) -> Timestamp
Adds the given amount of hours to the timestamp and returns the result. The original value remains unchanged.
Panics if the result exceeds the value range of Timestamp
.
Sourcepub const fn plus_minutes(&self, addition: u64) -> Timestamp
pub const fn plus_minutes(&self, addition: u64) -> Timestamp
Adds the given amount of minutes to the timestamp and returns the result. The original value remains unchanged.
Panics if the result exceeds the value range of Timestamp
.
Sourcepub const fn plus_seconds(&self, addition: u64) -> Timestamp
pub const fn plus_seconds(&self, addition: u64) -> Timestamp
Adds the given amount of seconds to the timestamp and returns the result. The original value remains unchanged.
Panics if the result exceeds the value range of Timestamp
.
Sourcepub const fn plus_nanos(&self, addition: u64) -> Timestamp
pub const fn plus_nanos(&self, addition: u64) -> Timestamp
Adds the given amount of nanoseconds to the timestamp and returns the result. The original value remains unchanged.
Panics if the result exceeds the value range of Timestamp
.
Sourcepub const fn minus_days(&self, subtrahend: u64) -> Timestamp
pub const fn minus_days(&self, subtrahend: u64) -> Timestamp
Subtracts the given amount of days from the timestamp and returns the result. The original value remains unchanged.
Panics if the result is not >= 0. I.e. times before epoch cannot be represented.
Sourcepub const fn minus_hours(&self, subtrahend: u64) -> Timestamp
pub const fn minus_hours(&self, subtrahend: u64) -> Timestamp
Subtracts the given amount of hours from the timestamp and returns the result. The original value remains unchanged.
Panics if the result is not >= 0. I.e. times before epoch cannot be represented.
Sourcepub const fn minus_minutes(&self, subtrahend: u64) -> Timestamp
pub const fn minus_minutes(&self, subtrahend: u64) -> Timestamp
Subtracts the given amount of minutes from the timestamp and returns the result. The original value remains unchanged.
Panics if the result is not >= 0. I.e. times before epoch cannot be represented.
Sourcepub const fn minus_seconds(&self, subtrahend: u64) -> Timestamp
pub const fn minus_seconds(&self, subtrahend: u64) -> Timestamp
Subtracts the given amount of seconds from the timestamp and returns the result. The original value remains unchanged.
Panics if the result is not >= 0. I.e. times before epoch cannot be represented.
Sourcepub const fn minus_nanos(&self, subtrahend: u64) -> Timestamp
pub const fn minus_nanos(&self, subtrahend: u64) -> Timestamp
Subtracts the given amount of nanoseconds from the timestamp and returns the result. The original value remains unchanged.
Panics if the result is not >= 0. I.e. times before epoch cannot be represented.
Sourcepub fn subsec_nanos(&self) -> u64
pub fn subsec_nanos(&self) -> u64
Returns nanoseconds since the last whole second (the remainder truncated
by seconds()
)
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Timestamp
impl<'de> Deserialize<'de> for Timestamp
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl From<Timestamp> for IbcTimeout
impl From<Timestamp> for IbcTimeout
Source§fn from(timestamp: Timestamp) -> IbcTimeout
fn from(timestamp: Timestamp) -> IbcTimeout
Source§impl JsonSchema for Timestamp
impl JsonSchema for Timestamp
Source§fn schema_name() -> String
fn schema_name() -> String
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn is_referenceable() -> bool
fn is_referenceable() -> bool
$ref
keyword. Read moreSource§impl Ord for Timestamp
impl Ord for Timestamp
Source§impl PartialOrd for Timestamp
impl PartialOrd for Timestamp
impl 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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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 more