Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement PackedPatternsV1 with packing and unpacking #5580

Merged
merged 27 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions components/datetime/src/pattern/runtime/pattern.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use super::super::{reference, PatternError, PatternItem, TimeGranularity};
use alloc::vec::Vec;
use core::str::FromStr;
use icu_plurals::provider::FourBitMetadata;
use icu_provider::prelude::*;
use zerovec::{ule::AsULE, ZeroSlice, ZeroVec};

Expand Down Expand Up @@ -75,6 +76,15 @@ impl PatternMetadata {
pub(crate) fn set_time_granularity(&mut self, time_granularity: TimeGranularity) {
self.0 = time_granularity.ordinal();
}

pub(crate) fn to_four_bit_metadata(self) -> FourBitMetadata {
#[allow(clippy::unwrap_used)] // valid values for self.0 are 0, 1, 2, 3, or 4
FourBitMetadata::try_from_byte(self.0).unwrap()
}

pub(crate) fn from_u8(other: u8) -> Self {
Self(TimeGranularity::from_ordinal(other).ordinal())
}
}

impl Default for PatternMetadata {
Expand Down
1 change: 1 addition & 0 deletions components/datetime/src/provider/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

pub mod calendar;
pub(crate) mod date_time;
pub mod packed_pattern;
pub mod time_zones;

/// Module for new DateSymbols design
Expand Down
Loading