icu_datetime
icu_datetime
is one of the ICU4X
components.
This API provides necessary functionality for formatting date and time to user readable textual representation.
[DateTimeFormat
] is the main structure of the component. It accepts a set of arguments which
allow it to collect necessary data from the data provider, and once instantiated, can be
used to quickly format any date and time provided.
Examples
use locale;
use Gregorian;
use ;
let provider = get_provider;
// See the next code example for a more ergonomic example with .into().
let options = Length;
let dtf = try_new
.expect;
let date = parse_gregorian_from_str
.expect;
let formatted_date = dtf.format;
assert_eq!;
The options can be created more ergonomically using the Into
trait to automatically
convert a [options::length::Bag
] into a [DateTimeFormatOptions::Length
].
use Gregorian;
use ;
let options = from_date_time_style.into;
let dtf = try_new;
At the moment, the crate provides only options using the Length
bag, but in the future,
we expect to add more ways to customize the output, like skeletons, and components.
Notice: Rust at the moment does not have a canonical way to represent date and time. We use
DateTime
as an example of the data necessary for ICU [DateTimeFormat
] to work, and
we hope to work with the community
to develop core date and time APIs that will work as an input for this component. DateTime
additionally
has support for non-Gregorian calendars, which this module will eventually be able to format.
More Information
For more information on development, authorship, contributing etc. please visit ICU4X home page
.