Struct DelayedFormat

pub struct DelayedFormat<I> { /* private fields */ }

A temporary object which can be used as an argument to format! or others. This is normally constructed via format methods of each date and time type.

Implementations

impl<'a, I: Iterator<Item = B> + Clone, B: Borrow<Item<'a>>> DelayedFormat<I>

fn new(date: Option<NaiveDate>, time: Option<NaiveTime>, items: I) -> DelayedFormat<I>

Makes a new DelayedFormat value out of local date and time.

fn new_with_offset<Off>(date: Option<NaiveDate>, time: Option<NaiveTime>, offset: &Off, items: I) -> DelayedFormat<I>
where
    Off: Offset + Display,

Makes a new DelayedFormat value out of local date and time and UTC offset.

fn write_to(&self, w: &mut impl Write + ?Sized) -> Result

Formats DelayedFormat into a core::fmt::Write instance.

Errors

This function returns a core::fmt::Error if formatting into the core::fmt::Write instance fails.

Example

Writing to a String

let dt = chrono::DateTime::from_timestamp(1643723400, 123456789).unwrap();
let df = dt.format("%Y-%m-%d %H:%M:%S%.9f");
let mut buffer = String::new();
let _ = df.write_to(&mut buffer);

Trait Implementations

impl<'a, I: Iterator<Item = B> + Clone, B: Borrow<Item<'a>>> Display for DelayedFormat<I>

fn fmt(&self, f: &mut Formatter<'_>) -> Result

impl<I: Debug> Debug for DelayedFormat<I>

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Auto Trait Implementations

impl<I> Freeze for DelayedFormat<I> where I: Freeze,

impl<I> RefUnwindSafe for DelayedFormat<I> where I: RefUnwindSafe,

impl<I> Send for DelayedFormat<I> where I: Send,

impl<I> Sync for DelayedFormat<I> where I: Sync,

impl<I> Unpin for DelayedFormat<I> where I: Unpin,

impl<I> UnsafeUnpin for DelayedFormat<I> where I: UnsafeUnpin,

impl<I> UnwindSafe for DelayedFormat<I> where I: UnwindSafe,

Blanket Implementations

impl<T> Any for DelayedFormat<I> where T: 'static + ?Sized,

fn type_id(&self) -> TypeId

impl<T> Borrow<T> for DelayedFormat<I> where T: ?Sized,

fn borrow(&self) -> &T

impl<T> BorrowMut<T> for DelayedFormat<I> where T: ?Sized,

fn borrow_mut(&mut self) -> &mut T

impl<T> From<T> for DelayedFormat<I>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> ToString for DelayedFormat<I> where T: Display + ?Sized,

fn to_string(&self) -> String

impl<T, U> Into<U> for DelayedFormat<I> where U: From<T>,

fn into(self) -> U

Calls U::from(self).

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

impl<T, U> TryFrom<U> for DelayedFormat<I> where U: Into<T>,

type Error = never;
fn try_from(value: U) -> Result<T, never>

impl<T, U> TryInto<U> for DelayedFormat<I> where U: TryFrom<T>,

type Error = <U as TryFrom<T>>::Error;
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>