Struct identity_core::common::Timestamp
source · #[repr(transparent)]pub struct Timestamp(_);
Expand description
A parsed Timestamp.
Implementations§
source§impl Timestamp
impl Timestamp
sourcepub fn parse(input: &str) -> Result<Self>
pub fn parse(input: &str) -> Result<Self>
Parses a Timestamp
from the provided input string, normalized to UTC+00:00 with fractional
seconds truncated.
See the datetime
DID-core specification.
sourcepub fn now_utc() -> Self
pub fn now_utc() -> Self
Creates a new Timestamp
with the current date and time, normalized to UTC+00:00 with
fractional seconds truncated.
See the datetime
DID-core specification.
sourcepub fn to_rfc3339(&self) -> String
pub fn to_rfc3339(&self) -> String
Returns the Timestamp
as an RFC 3339 String
.
sourcepub fn from_unix(seconds: i64) -> Result<Self>
pub fn from_unix(seconds: i64) -> Result<Self>
Creates a new Timestamp
from the given Unix timestamp.
The timestamp must be in the valid range for RFC 3339.
Errors
Error::InvalidTimestamp
if seconds
is outside of the interval [-62167219200,253402300799].
sourcepub fn checked_add(self, duration: Duration) -> Option<Self>
pub fn checked_add(self, duration: Duration) -> Option<Self>
Computes self + duration
Returns None
if the operation leads to a timestamp not in the valid range for RFC 3339.
sourcepub fn checked_sub(self, duration: Duration) -> Option<Self>
pub fn checked_sub(self, duration: Duration) -> Option<Self>
Computes self - duration
Returns None
if the operation leads to a timestamp not in the valid range for RFC 3339.
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 Diff for Timestamp
impl Diff for Timestamp
§type Type = DiffString
type Type = DiffString
source§fn diff(&self, other: &Self) -> Result<Self::Type>
fn diff(&self, other: &Self) -> Result<Self::Type>
self
and other
and returns Self::Type
source§fn merge(&self, diff: Self::Type) -> Result<Self>
fn merge(&self, diff: Self::Type) -> Result<Self>
Self::Type
with Self
source§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
self
and other
) and is used by the <=
operator. Read more