1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
// This file is part of ICU4X. For terms of use, please see the file // called LICENSE at the top level of the ICU4X source tree // (online at: https://github.com/unicode-org/icu4x/blob/master/LICENSE ). //! `DateTimeFormatOptions` is a bag of options which, together with `LanguageIdentifier`, //! define how dates will be formatted be a `DateTimeFormat` instance. //! //! Each variant of the bag is a combination of settings definiting how to format //! the date, with an optional `Preferences` which represent user preferences and //! may alter how the selected pattern is formatted. //! //! # Examples //! //! ``` //! use icu_datetime::{DateTimeFormatOptions, options::style}; //! //! let options = DateTimeFormatOptions::Style( //! style::Bag { //! date: Some(style::Date::Medium), //! time: Some(style::Time::Short), //! ..Default::default() //! } //! ); //! ``` //! //! At the moment only the `Style` bag works, and we plan to extend that to support //! `ECMA 402` like components bag later. pub mod components; pub mod preferences; pub mod style; /// `DateTimeFormatOptions` is a bag of options which, together with `LanguageIdentifier`, /// define how dates will be formatted be a `DateTimeFormat` instance. /// /// Each variant of the bag is a combination of settings definiting how to format /// the date, with an optional `Preferences` which represent user preferences and /// may alter how the selected pattern is formatted. /// /// # Examples /// /// ``` /// use icu_datetime::{DateTimeFormatOptions, options::style}; /// /// let options = DateTimeFormatOptions::Style( /// style::Bag { /// date: Some(style::Date::Medium), /// time: Some(style::Time::Short), /// ..Default::default() /// } /// ); /// ``` /// /// At the moment only the `Style` bag works, and we plan to extend that to support /// `ECMA 402` like components bag later. #[derive(Debug)] pub enum DateTimeFormatOptions { /// Bag of styles for date and time Style(style::Bag), /// Bag of components describing which fields and how should be displayed Components(components::Bag), } impl Default for DateTimeFormatOptions { fn default() -> Self { Self::Style(style::Bag::default()) } } impl From<style::Bag> for DateTimeFormatOptions { fn from(input: style::Bag) -> Self { Self::Style(input) } } impl From<components::Bag> for DateTimeFormatOptions { fn from(input: components::Bag) -> Self { Self::Components(input) } }