Struct icu_datetime::FormattedDateTime
source · pub struct FormattedDateTime<'l> { /* private fields */ }
Expand description
FormattedDateTime
is a intermediate structure which can be retrieved as
an output from TypedDateTimeFormatter
.
The structure contains all the information needed to display formatted value, and it will also contain additional methods allowing the user to introspect and even manipulate the formatted data.
Examples
use icu::calendar::{DateTime, Gregorian};
use icu::datetime::TypedDateTimeFormatter;
use icu::locid::locale;
let dtf = TypedDateTimeFormatter::<Gregorian>::try_new(
&locale!("en").into(),
Default::default(),
)
.expect("Failed to create TypedDateTimeFormatter instance.");
let datetime = DateTime::try_new_gregorian_datetime(2020, 9, 1, 12, 34, 28)
.expect("Failed to construct DateTime.");
let formatted_date = dtf.format(&datetime);
let _ = format!("Date: {}", formatted_date);
Trait Implementations§
source§impl<'l> Debug for FormattedDateTime<'l>
impl<'l> Debug for FormattedDateTime<'l>
source§impl<'l> Display for FormattedDateTime<'l>
impl<'l> Display for FormattedDateTime<'l>
source§impl<'l> Writeable for FormattedDateTime<'l>
impl<'l> Writeable for FormattedDateTime<'l>
source§fn write_to<W: Write + ?Sized>(&self, sink: &mut W) -> Result
fn write_to<W: Write + ?Sized>(&self, sink: &mut W) -> Result
Writes a string to the given sink. Errors from the sink are bubbled up.
The default implementation delegates to
write_to_parts
, and discards any
Part
annotations.source§fn write_to_parts<S>(&self, sink: &mut S) -> Result<(), Error>where
S: PartsWrite + ?Sized,
fn write_to_parts<S>(&self, sink: &mut S) -> Result<(), Error>where S: PartsWrite + ?Sized,
Write bytes and
Part
annotations to the given sink. Errors from the
sink are bubbled up. The default implementation delegates to write_to
,
and doesn’t produce any Part
annotations.source§fn writeable_length_hint(&self) -> LengthHint
fn writeable_length_hint(&self) -> LengthHint
Returns a hint for the number of UTF-8 bytes that will be written to the sink. Read more
Auto Trait Implementations§
impl<'l> RefUnwindSafe for FormattedDateTime<'l>
impl<'l> Send for FormattedDateTime<'l>
impl<'l> Sync for FormattedDateTime<'l>
impl<'l> Unpin for FormattedDateTime<'l>
impl<'l> UnwindSafe for FormattedDateTime<'l>
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