pub struct TimestampDisplayWithOffset { /* private fields */ }Expand description
A type for formatting a Timestamp with a specific offset.
This type is created by the Timestamp::display_with_offset method.
Like the std::fmt::Display trait implementation for Timestamp, this
always emits an RFC 3339 compliant string. Unlike Timestamp’s Display
trait implementation, which always uses Z or “Zulu” time, this always
uses an offset.
§Formatting options supported
std::fmt::Formatter::precisioncan be set to control the precision of the fractional second component.
§Example
use jiff::{tz, Timestamp};
let offset = tz::offset(-5);
let ts = Timestamp::new(1_123_456_789, 123_000_000)?;
assert_eq!(
format!("{ts:.6}", ts = ts.display_with_offset(offset)),
"2005-08-07T18:19:49.123000-05:00",
);
// Precision values greater than 9 are clamped to 9.
assert_eq!(
format!("{ts:.300}", ts = ts.display_with_offset(offset)),
"2005-08-07T18:19:49.123000000-05:00",
);
// A precision of 0 implies the entire fractional
// component is always truncated.
assert_eq!(
format!("{ts:.0}", ts = ts.display_with_offset(tz::Offset::UTC)),
"2005-08-07T23:19:49+00:00",
);
Trait Implementations§
Source§impl Clone for TimestampDisplayWithOffset
impl Clone for TimestampDisplayWithOffset
Source§fn clone(&self) -> TimestampDisplayWithOffset
fn clone(&self) -> TimestampDisplayWithOffset
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for TimestampDisplayWithOffset
Source§impl Debug for TimestampDisplayWithOffset
impl Debug for TimestampDisplayWithOffset
Auto Trait Implementations§
impl Forget for TimestampDisplayWithOffset
impl Freeze for TimestampDisplayWithOffset
impl Move for TimestampDisplayWithOffset
impl RefUnwindSafe for TimestampDisplayWithOffset
impl Send for TimestampDisplayWithOffset
impl Sync for TimestampDisplayWithOffset
impl Unpin for TimestampDisplayWithOffset
impl UnsafeUnpin for TimestampDisplayWithOffset
impl UnwindSafe for TimestampDisplayWithOffset
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<K> ForeignKey<K> for K
impl<K> ForeignKey<K> for K
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoMarkdown for Twhere
T: Display,
impl<T> IntoMarkdown for Twhere
T: Display,
Creates a shared type from an unshared type.