pub trait DateTimeFormat {
    type Error: Error;

    // Required methods
    fn try_new<L>(
        l: L,
        opts: DateTimeFormatOptions
    ) -> Result<Self, Self::Error>
       where L: Locale,
             Self: Sized;
    fn format<W>(&self, date: f64, writer: &mut W) -> Result
       where W: Write;
}

Required Associated Types§

source

type Error: Error

The type of error reported, if any.

Required Methods§

source

fn try_new<L>(l: L, opts: DateTimeFormatOptions) -> Result<Self, Self::Error>
where L: Locale, Self: Sized,

Creates a new DateTimeFormat.

Creation may fail, for example, if the locale-specific data is not loaded, or if the supplied options are inconsistent.

source

fn format<W>(&self, date: f64, writer: &mut W) -> Result
where W: Write,

Formats date into the supplied standard writer fmt::Write.

The original ECMA 402 function returns a string. This is likely the only reasonably generic option in JavaScript so it is adequate. In Rust, however, it is possible to pass in a standard formatting strategy (through writer).

The date holds the number of seconds (with fractional part) since the beginning of the Unix epoch. The date is a very generic type because there is no official date-time type in Rust.

Object Safety§

This trait is not object safe.

Implementors§