pub struct TimestampIso8601Display { /* private fields */ }
Expand description

Display implementation to format a Timestamp in an ISO 8601 format.

Examples

Format a timestamp as an ISO 8601 datetime both with microseconds:

use twilight_model::util::Timestamp;

let timestamp = Timestamp::from_micros(1_628_594_197_020_000)?;
assert_eq!(
    "2021-08-10T11:16:37.020000+00:00",
    timestamp.iso_8601().to_string(),
);

Implementations§

Get the inner timestamp.

Whether to format the timestamp with microseconds.

The ISO 8601 display formatter formats with microseconds by default.

Examples

Format a timestamp with microseconds:

use twilight_model::util::Timestamp;

let timestamp = Timestamp::from_micros(1_628_594_197_020_000)?;
let formatter = timestamp.iso_8601().with_microseconds(true);

assert_eq!("2021-08-10T11:16:37.020000+00:00", formatter.to_string());

Format a timestamp without microseconds:

use twilight_model::util::Timestamp;

let timestamp = Timestamp::from_micros(1_628_594_197_020_000)?;
let formatter = timestamp.iso_8601().with_microseconds(false);

assert_eq!("2021-08-10T11:16:37+00:00", formatter.to_string());

Trait Implementations§

Formats the value using the given formatter. Read more
Formats the value using the given formatter. Read more
Serialize this value into the given Serde serializer. Read more

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

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

Calls U::from(self).

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

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