Skip to content

Commit

Permalink
Initial RawNeoDateTimeFormatter data model
Browse files Browse the repository at this point in the history
  • Loading branch information
sffc committed Dec 9, 2023
1 parent f4a8899 commit 43f03f1
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
2 changes: 2 additions & 0 deletions components/datetime/src/raw/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

/// Untyped versions of TypedDateTimeFormatter and TypedZonedDateTimeFormatter
mod datetime;
#[cfg(feature = "experimental")]
mod neo;
mod zoned_datetime;

pub(crate) use datetime::{DateFormatter, DateTimeFormatter, TimeFormatter};
Expand Down
56 changes: 56 additions & 0 deletions components/datetime/src/raw/neo.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// 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 icu_provider::prelude::*;
use crate::provider::neo::*;
use crate::format::neo::*;

pub(crate) enum DatePatternSelectionData {
SingleDate(DataPayload<ErasedDatePatternV1Marker>),
OptionalEra {
with_era: DataPayload<ErasedDatePatternV1Marker>,
without_era: DataPayload<ErasedDatePatternV1Marker>,
},
}

pub(crate) enum TimePatternData {
SingleTime(DataPayload<TimePatternV1Marker>),
}

pub(crate) enum DateTimePatternSelectionData {
Date(DatePatternSelectionData),
Time(TimePatternData),
Glue(DataPayload<DateTimePatternV1Marker>),
}

pub(crate) struct TypedNeoDateTimeFormatter<C: CldrCalendar> {
names: TypedDateTimeNames<C>,
}

pub(crate) struct RawNeoDateTimeFormatter {
names: RawDateTimeNames,
selection: DateTimePatternSelectionData,
}

#[cfg(test)]
mod tests {
use icu_calendar::week::WeekCalculator;
use icu_decimal::FixedDecimalFormatter;

use super::*;

#[test]
fn test_sizes() {
assert_eq!(48, core::mem::size_of::<DataPayload<ErasedDatePatternV1Marker>>());
assert_eq!(80, core::mem::size_of::<DataLocale>());
assert_eq!(216, core::mem::size_of::<FixedDecimalFormatter>());
assert_eq!(2, core::mem::size_of::<WeekCalculator>());
assert_eq!(72, core::mem::size_of::<DataPayload<ErasedYearNamesV1Marker>>());
assert_eq!(56, core::mem::size_of::<DataPayload<ErasedMonthNamesV1Marker>>());
assert_eq!(40, core::mem::size_of::<DataPayload<WeekdayNamesV1Marker>>());
assert_eq!(40, core::mem::size_of::<DataPayload<DayPeriodNamesV1Marker>>());
assert_eq!(640, core::mem::size_of::<RawNeoDateTimeFormatter>());
}
}

0 comments on commit 43f03f1

Please sign in to comment.