Struct catenis_api_client::UtcDateTime [−][src]
pub struct UtcDateTime { /* fields omitted */ }
Expand description
Represents a date and time in reference to the UTC timezone.
This should be used for manipulating date and time data received from/sent to the Catenis API.
Examples
Converting from and to string.
use catenis_api_client::{
UtcDateTime,
};
let date_time: UtcDateTime = "2020-12-29T10:49:25Z".into();
assert_eq!(date_time.to_string(), "2020-12-29T10:49:25.000Z");
Converting from and to time
crate’s data structures.
use time::OffsetDateTime;
use catenis_api_client::{
UtcDateTime,
};
// Date
let date = time::date!(2020-12-29);
let date_time: UtcDateTime = date.into();
assert_eq!(date_time.to_string(), "2020-12-29T00:00:00.000Z");
// PrimitiveDateTime
let primitive_date_time = time::date!(2020-12-29).with_time(time::time!(10:49:25));
let date_time: UtcDateTime = primitive_date_time.into();
assert_eq!(date_time.to_string(), "2020-12-29T10:49:25.000Z");
// OffsetDateTime
let offset_date_time = time::date!(2020-12-29).with_time(time::time!(10:49:25)).assume_utc();
let date_time: UtcDateTime = offset_date_time.into();
assert_eq!(date_time.to_string(), "2020-12-29T10:49:25.000Z");
let offset_date_time_2: OffsetDateTime = date_time.into();
assert_eq!(offset_date_time_2, offset_date_time);
Implementations
Trait Implementations
Performs the conversion.
fn deserialize<D>(deserializer: D) -> Result<UtcDateTime, D::Error> where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<UtcDateTime, D::Error> where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
This method tests for !=
.
Auto Trait Implementations
impl RefUnwindSafe for UtcDateTime
impl Send for UtcDateTime
impl Sync for UtcDateTime
impl Unpin for UtcDateTime
impl UnwindSafe for UtcDateTime
Blanket Implementations
Mutably borrows from an owned value. Read more
Compare self to key
and return true
if they are equal.
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more