Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
sffc committed Oct 25, 2023
1 parent 7559dc5 commit 6463a4e
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 0 deletions.
3 changes: 3 additions & 0 deletions components/datetime/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions components/datetime/src/format/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
72 changes: 72 additions & 0 deletions components/datetime/src/format/neo.rs
Original file line number Diff line number Diff line change
@@ -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;

Check warning on line 11 in components/datetime/src/format/neo.rs

View workflow job for this annotation

GitHub Actions / Docs Preview

unused import: `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<C: CldrCalendar> {
year_symbols: Option<DataPayload<C::YearSymbolsV1Marker>>,
month_symbols: Option<DataPayload<C::MonthSymbolsV1Marker>>,
weekday_symbols: Option<DataPayload<WeekdaySymbolsV1Marker>>,
dayperiod_symbols: Option<DataPayload<DayPeriodSymbolsV1Marker>>,
fixed_decimal_formatter: Option<FixedDecimalFormatter>,
}

struct ErasedDateTimePatternInterpolator {
year_symbols: Option<DataPayload<ErasedYearSymbolsV1Marker>>,
month_symbols: Option<DataPayload<ErasedMonthSymbolsV1Marker>>,
weekday_symbols: Option<DataPayload<WeekdaySymbolsV1Marker>>,
dayperiod_symbols: Option<DataPayload<DayPeriodSymbolsV1Marker>>,
fixed_decimal_formatter: Option<FixedDecimalFormatter>,
}

impl<'data> DateSymbols<'data> for ErasedDateTimePatternInterpolator {
fn get_symbol_for_month(
&self,
month: fields::Month,

Check warning on line 39 in components/datetime/src/format/neo.rs

View workflow job for this annotation

GitHub Actions / Docs Preview

unused variable: `month`
length: fields::FieldLength,

Check warning on line 40 in components/datetime/src/format/neo.rs

View workflow job for this annotation

GitHub Actions / Docs Preview

unused variable: `length`
code: MonthCode,

Check warning on line 41 in components/datetime/src/format/neo.rs

View workflow job for this annotation

GitHub Actions / Docs Preview

unused variable: `code`
) -> Result<(&str, bool), Error> {
todo!()
}

fn get_symbol_for_weekday(
&self,
weekday: fields::Weekday,

Check warning on line 48 in components/datetime/src/format/neo.rs

View workflow job for this annotation

GitHub Actions / Docs Preview

unused variable: `weekday`
length: fields::FieldLength,

Check warning on line 49 in components/datetime/src/format/neo.rs

View workflow job for this annotation

GitHub Actions / Docs Preview

unused variable: `length`
day: input::IsoWeekday,

Check warning on line 50 in components/datetime/src/format/neo.rs

View workflow job for this annotation

GitHub Actions / Docs Preview

unused variable: `day`
) -> Result<&str, Error> {
todo!()
}

fn get_symbol_for_era<'a>(&'a self, length: fields::FieldLength, era_code: &'a Era) -> &str {

Check warning on line 55 in components/datetime/src/format/neo.rs

View workflow job for this annotation

GitHub Actions / Docs Preview

unused variable: `length`

Check warning on line 55 in components/datetime/src/format/neo.rs

View workflow job for this annotation

GitHub Actions / Docs Preview

unused variable: `era_code`
todo!()
}
}

impl<C: CldrCalendar> DateTimePatternInterpolator<C> {
pub fn format_pattern<T, W>(
pattern: &Pattern,

Check warning on line 62 in components/datetime/src/format/neo.rs

View workflow job for this annotation

GitHub Actions / Docs Preview

unused variable: `pattern`
datetime: &impl LocalizedDateTimeInput<T>,
writeable: &mut W,
) -> Result<(), Error>
where
T: DateTimeInput,
W: fmt::Write + ?Sized,
{
unimplemented!()
}
}
11 changes: 11 additions & 0 deletions components/datetime/src/provider/neo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
Expand Down Expand Up @@ -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>;
}
3 changes: 3 additions & 0 deletions components/datetime/src/provider/neo/impls.rs
Original file line number Diff line number Diff line change
@@ -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 ).

0 comments on commit 6463a4e

Please sign in to comment.