Struct twilight_model::util::datetime::TimestampIso8601Display
source · [−]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
sourceimpl TimestampIso8601Display
impl TimestampIso8601Display
sourcepub const fn with_microseconds(self, with_microseconds: bool) -> Self
pub const fn with_microseconds(self, with_microseconds: bool) -> Self
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
sourceimpl Debug for TimestampIso8601Display
impl Debug for TimestampIso8601Display
sourceimpl Display for TimestampIso8601Display
impl Display for TimestampIso8601Display
sourceimpl Serialize for TimestampIso8601Display
impl Serialize for TimestampIso8601Display
Auto Trait Implementations
impl RefUnwindSafe for TimestampIso8601Display
impl Send for TimestampIso8601Display
impl Sync for TimestampIso8601Display
impl Unpin for TimestampIso8601Display
impl UnwindSafe for TimestampIso8601Display
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber to this type, returning a
WithDispatch wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber to this type, returning a
WithDispatch wrapper. Read more