-
Notifications
You must be signed in to change notification settings - Fork 182
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DurationFormatter: Digital Data Provider SourceDataProvider impl (#5208)
- Loading branch information
Showing
30 changed files
with
630 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
// 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 ). | ||
|
||
// Provider structs must be stable | ||
#![allow(clippy::exhaustive_structs, clippy::exhaustive_enums)] | ||
|
||
//! Provider structs for digital data. | ||
use alloc::borrow::Cow; | ||
use icu_provider::prelude::*; | ||
|
||
#[icu_provider::data_struct(DigitalDurationDataV1Marker = "duration/digital@1")] | ||
#[derive(Debug, Clone, PartialEq)] | ||
#[cfg_attr( | ||
feature = "datagen", | ||
derive(serde::Serialize, databake::Bake), | ||
databake(path = icu_experimental::duration::provider) | ||
)] | ||
#[cfg_attr(feature = "serde", derive(serde::Deserialize))] | ||
|
||
/// A struct containing digital duration data (durationUnit-type-* patterns). | ||
pub struct DigitalDurationDataV1<'data> { | ||
/// The separator between the hour, minute, and second fields. | ||
#[cfg_attr(feature = "serde", serde(borrow))] | ||
pub separator: Cow<str, 'data>, | ||
|
||
/// The number of digits to pad hours when hour, minutes and seconds must be displayed. | ||
/// Calculated from the hms pattern. | ||
pub hms_padding: HmsPadding, | ||
|
||
/// The number of digits to pad hours when only hour and minutes must be displayed. | ||
/// Calculated from the hm pattern. | ||
pub hm_padding: HmPadding, | ||
|
||
/// The number of digits to pad minutes when only minutes and seconds must be displayed. | ||
/// Calculated from the ms pattern. | ||
pub ms_padding: MsPadding, | ||
} | ||
|
||
#[derive(Debug, Clone, Copy, PartialEq)] | ||
#[cfg_attr( | ||
feature = "datagen", | ||
derive(serde::Serialize, databake::Bake), | ||
databake(path = icu_experimental::duration::provider) | ||
)] | ||
#[cfg_attr(feature = "serde", derive(serde::Deserialize))] | ||
/// A struct containing the number of digits to pad hours, minutes, and seconds. | ||
pub struct HmsPadding { | ||
/// Hour padding. | ||
pub h: u8, | ||
/// Minute padding. | ||
pub m: u8, | ||
/// Second padding. | ||
pub s: u8, | ||
} | ||
|
||
#[derive(Debug, Clone, Copy, PartialEq)] | ||
#[cfg_attr( | ||
feature = "datagen", | ||
derive(serde::Serialize, databake::Bake), | ||
databake(path = icu_experimental::duration::provider) | ||
)] | ||
#[cfg_attr(feature = "serde", derive(serde::Deserialize))] | ||
/// A struct containing the number of digits to pad minutes, and seconds. | ||
pub struct MsPadding { | ||
/// Minute padding. | ||
pub m: u8, | ||
/// Second padding. | ||
pub s: u8, | ||
} | ||
|
||
#[derive(Debug, Clone, Copy, PartialEq)] | ||
#[cfg_attr( | ||
feature = "datagen", | ||
derive(serde::Serialize, databake::Bake), | ||
databake(path = icu_experimental::duration::provider) | ||
)] | ||
#[cfg_attr(feature = "serde", derive(serde::Deserialize))] | ||
/// A struct containing the number of digits to pad hours and minutes. | ||
pub struct HmPadding { | ||
/// Hour padding. | ||
pub h: u8, | ||
/// Minute padding. | ||
pub m: u8, | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
provider/data/experimental/data/digital_duration_data_v1_marker.rs.data
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
provider/data/experimental/stubdata/digital_duration_data_v1_marker.rs.data
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.