Struct cosmwasm_std::Timestamp
source · 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
pub const fn plus_days(&self, addition: u64) -> Timestamp
pub const fn plus_hours(&self, addition: u64) -> Timestamp
pub const fn plus_minutes(&self, addition: u64) -> Timestamp
pub const fn plus_seconds(&self, addition: u64) -> Timestamp
pub const fn plus_nanos(&self, addition: u64) -> Timestamp
pub const fn minus_days(&self, subtrahend: u64) -> Timestamp
pub const fn minus_hours(&self, subtrahend: u64) -> Timestamp
pub const fn minus_minutes(&self, subtrahend: 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 schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Returns a string that uniquely identifies the schema produced by this type. 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 for Timestamp
impl PartialEq for Timestamp
source§impl PartialOrd for Timestamp
impl PartialOrd 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 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
Mutably borrows from an owned value. Read more