Struct cosmwasm_std::Timestamp
source · pub struct Timestamp(_);
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
pub const fn plus_seconds(&self, addition: u64) -> Timestamp
pub const fn plus_nanos(&self, addition: u64) -> Timestamp
pub const fn minus_seconds(&self, subtrahend: u64) -> Timestamp
pub const fn minus_nanos(&self, subtrahend: u64) -> Timestamp
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>,
Deserialize this value from the given Serde deserializer. Read more
source§impl From<Timestamp> for IbcTimeout
impl From<Timestamp> for IbcTimeout
source§fn from(timestamp: Timestamp) -> IbcTimeout
fn from(timestamp: Timestamp) -> IbcTimeout
Converts to this type from the input type.
source§impl JsonSchema for Timestamp
impl JsonSchema for Timestamp
source§fn schema_name() -> String
fn schema_name() -> String
The name of the generated JSON Schema. Read more
source§fn json_schema(gen: &mut SchemaGenerator) -> Schema
fn json_schema(gen: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
source§fn is_referenceable() -> bool
fn is_referenceable() -> bool
Whether JSON Schemas generated for this type should be re-used where possible using the
$ref
keyword. Read moresource§impl Ord for Timestamp
impl Ord for Timestamp
source§impl PartialEq<Timestamp> for Timestamp
impl PartialEq<Timestamp> for Timestamp
source§impl PartialOrd<Timestamp> for Timestamp
impl PartialOrd<Timestamp> for Timestamp
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read more