diff --git a/components/datetime/src/error.rs b/components/datetime/src/error.rs index 47ba9bbdefc..0cb4b759a3b 100644 --- a/components/datetime/src/error.rs +++ b/components/datetime/src/error.rs @@ -71,6 +71,9 @@ pub enum DateTimeError { /// Missing time symbols #[displaydoc("Missing time symbols")] MissingTimeSymbols, + /// Missing symbols of a particular type + #[displaydoc("Missing symbols for {0}")] + MissingSymbols(&'static str), /// ordinal_rules must be set for PatternPlurals::MultipleVariants #[displaydoc("ordinal_rules must be set for PatternPlurals::MultipleVariants")] MissingOrdinalRules, diff --git a/components/datetime/src/format/mod.rs b/components/datetime/src/format/mod.rs index 959d5f0d0b5..fab9f66f4db 100644 --- a/components/datetime/src/format/mod.rs +++ b/components/datetime/src/format/mod.rs @@ -3,5 +3,6 @@ // (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ). pub mod datetime; +pub mod neo; pub mod time_zone; pub mod zoned_datetime; diff --git a/components/datetime/src/format/neo.rs b/components/datetime/src/format/neo.rs new file mode 100644 index 00000000000..418f6abef1d --- /dev/null +++ b/components/datetime/src/format/neo.rs @@ -0,0 +1,72 @@ +// 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/main/LICENSE ). + +use crate::calendar::CldrCalendar; +use crate::error::DateTimeError as Error; +use crate::fields; +use crate::input; +use crate::input::{DateTimeInput, LocalizedDateTimeInput}; +use crate::pattern::runtime::Pattern; +use crate::provider::calendar::months; +use crate::provider::date_time::DateSymbols; +use crate::provider::neo::*; +use core::fmt; +use icu_calendar::types::Era; +use icu_decimal::FixedDecimalFormatter; +use icu_provider::prelude::*; +use icu_calendar::types::MonthCode; + +pub struct DateTimePatternInterpolator { + year_symbols: Option>, + month_symbols: Option>, + weekday_symbols: Option>, + dayperiod_symbols: Option>, + fixed_decimal_formatter: Option, +} + +struct ErasedDateTimePatternInterpolator { + year_symbols: Option>, + month_symbols: Option>, + weekday_symbols: Option>, + dayperiod_symbols: Option>, + fixed_decimal_formatter: Option, +} + +impl<'data> DateSymbols<'data> for ErasedDateTimePatternInterpolator { + fn get_symbol_for_month( + &self, + month: fields::Month, + length: fields::FieldLength, + code: MonthCode, + ) -> Result<(&str, bool), Error> { + todo!() + } + + fn get_symbol_for_weekday( + &self, + weekday: fields::Weekday, + length: fields::FieldLength, + day: input::IsoWeekday, + ) -> Result<&str, Error> { + todo!() + } + + fn get_symbol_for_era<'a>(&'a self, length: fields::FieldLength, era_code: &'a Era) -> &str { + todo!() + } +} + +impl DateTimePatternInterpolator { + pub fn format_pattern( + pattern: &Pattern, + datetime: &impl LocalizedDateTimeInput, + writeable: &mut W, + ) -> Result<(), Error> + where + T: DateTimeInput, + W: fmt::Write + ?Sized, + { + unimplemented!() + } +} diff --git a/components/datetime/src/provider/neo.rs b/components/datetime/src/provider/neo.rs index b8e1a97ffa4..4b3fa80684b 100644 --- a/components/datetime/src/provider/neo.rs +++ b/components/datetime/src/provider/neo.rs @@ -3,6 +3,7 @@ // (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ). mod adapter; +mod impls; use crate::pattern::runtime; use icu_provider::prelude::*; @@ -242,3 +243,13 @@ pub struct DateTimePatternV1<'data> { #[cfg_attr(feature = "serde", serde(borrow))] pub pattern: runtime::GenericPattern<'data>, } + +pub(crate) struct ErasedYearSymbolsV1Marker; +impl DataMarker for ErasedYearSymbolsV1Marker { + type Yokeable = YearSymbolsV1<'static>; +} + +pub(crate) struct ErasedMonthSymbolsV1Marker; +impl DataMarker for ErasedMonthSymbolsV1Marker { + type Yokeable = MonthSymbolsV1<'static>; +} diff --git a/components/datetime/src/provider/neo/impls.rs b/components/datetime/src/provider/neo/impls.rs new file mode 100644 index 00000000000..1cbabc9e27a --- /dev/null +++ b/components/datetime/src/provider/neo/impls.rs @@ -0,0 +1,3 @@ +// 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/main/LICENSE ).