#[repr(transparent)]
pub struct Timestamp(_);
Expand description

RFC3339 timestamp

Implementations

Constructs a new Timestamp if it conforms to Timestamp

Constructs a new Timestamp without validation

Safety

Consumers of this function must ensure that values conform to Timestamp. Failure to maintain this invariant may lead to undefined behavior.

Converts this Timestamp into a Box<TimestampRef>

This will drop any excess capacity.

Unwraps the underlying String value

Available on crate feature time only.

Create a timestamp corresponding to current time

Available on crate feature time only.

Create a timestamp corresponding to the start of the current day. Timezone will always be UTC.

Methods from Deref<Target = TimestampRef>

Provides access to the underlying value as a string slice.

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 time2021 = Timestamp::new("2021-07-01T13:37:00Z").unwrap();
let time2020 = Timestamp::new("2020-07-01T13:37:00Z").unwrap();
assert!(time2020.is_before(&time2021));

Make a timestamp with the time component set to 00:00:00.

Examples
use twitch_api2::types::Timestamp;

let time = Timestamp::new("2021-07-01T13:37:00Z").unwrap();
assert_eq!(time.to_day().as_str(), "2021-07-01T00:00:00Z")
Available on crate feature time only.

Construct into a OffsetDateTime time with a guaranteed UTC offset.

Panics

This method assumes the timestamp is a valid rfc3339 timestamp, and panics if not.

Available on crate feature time only.

Construct into a OffsetDateTime time.

Panics

This method assumes the timestamp is a valid rfc3339 timestamp, and panics if not.

Trait Implementations

Converts this type into a shared reference of the (usually inferred) input type.

Converts this type into a shared reference of the (usually inferred) input type.

Immutably borrows from an owned value. Read more

Immutably borrows from an owned value. Read more

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

The resulting type after dereferencing.

Dereferences the value.

Deserialize this value from the given Serde deserializer. Read more

Formats the value using the given formatter. Read more

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

The associated error which can be returned from parsing.

Parses a string s to return a value of this type. Read more

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

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 tests greater than or equal to (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 tests greater than or equal to (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 tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Serialize this value into the given Serde serializer. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The error produced when the string is invalid

Validates a string according to a predetermined set of rules

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Compare self to key and return true if they are equal.

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

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