Struct twitch_api2::types::Timestamp [−][src]
#[repr(transparent)]pub struct Timestamp(_);
Expand description
RFC3339 timestamp
Implementations
Constructs a new Timestamp if it conforms to Timestamp
Converts this Timestamp
into a Box
<
TimestampRef
>
This will drop any excess capacity.
Unwraps the underlying String
value
Methods from Deref<Target = TimestampRef>
Normalize the timestamp into UTC time.
Examples
use twitch_api2::types::Timestamp;
let time = Timestamp::new("2021-07-01T13:37:00Z").unwrap();
assert_eq!(time.normalize()?.as_ref(), &time);
let time2 = Timestamp::new("2021-07-01T13:37:00-01:00").unwrap();
assert_ne!(time2.normalize()?.as_ref(), &time2);
Compare another time and return self < other
.
Examples
use twitch_api2::types::Timestamp;
let time1 = Timestamp::new("2021-07-01T13:37:00Z").unwrap();
let time2 = Timestamp::new("2021-07-01T13:36:00Z").unwrap();
assert!(time2.is_before(&time1));
let time_now = chrono::Utc::now();
assert!(time1.is_before(&time_now));
Construct into a DateTime<Utc>
time.
Panics
This method assumes the timestamp is a valid rfc3339 timestamp, and panics if not.
Construct into a DateTime<FixedOffset>
time.
Panics
This method assumes the timestamp is a valid rfc3339 timestamp, and panics if not.
Trait Implementations
Performs the conversion.
Immutably borrows from an owned value. Read more
type Target = TimestampRef
type Target = TimestampRef
The resulting type after dereferencing.
Deserialize this value from the given Serde deserializer. Read more
Performs the conversion.
Performs the conversion.
Performs the conversion.
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
Auto Trait Implementations
impl RefUnwindSafe for Timestamp
impl UnwindSafe for Timestamp
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
pub fn vzip(self) -> V
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more