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

DurationFormatter: Implement DurationFormatter #5321

Merged
merged 13 commits into from
Aug 13, 2024
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions components/experimental/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ icu_provider = { workspace = true, features = ["macros"] }
icu_locale_core = { workspace = true }

icu_decimal = { workspace = true }
icu_list = { workspace = true }
icu_locale = { workspace = true }
icu_normalizer = { workspace = true }
icu_plurals = { workspace = true }
Expand Down Expand Up @@ -66,10 +67,10 @@ icu_normalizer_data = { workspace = true }

[features]
default = ["compiled_data"]
compiled_data = ["dep:icu_experimental_data", "icu_decimal/compiled_data", "icu_plurals/compiled_data", "icu_properties/compiled_data", "icu_normalizer/compiled_data"]
compiled_data = ["dep:icu_experimental_data", "icu_decimal/compiled_data", "icu_list/compiled_data", "icu_plurals/compiled_data", "icu_properties/compiled_data", "icu_normalizer/compiled_data"]
datagen = ["serde", "std", "dep:databake", "zerovec/databake", "zerotrie/databake", "tinystr/databake", "icu_collections/databake", "std", "log", "icu_pattern/databake"]
ryu = ["fixed_decimal/ryu"]
serde = ["dep:serde", "zerovec/serde", "tinystr/serde", "icu_collections/serde", "icu_decimal/serde", "icu_pattern/serde", "icu_plurals/serde", "icu_provider/serde", "zerotrie/serde"]
serde = ["dep:serde", "zerovec/serde", "tinystr/serde", "icu_collections/serde", "icu_decimal/serde", "icu_list/serde", "icu_pattern/serde", "icu_plurals/serde", "icu_provider/serde", "zerotrie/serde"]
std = ["fixed_decimal/std", "icu_decimal/std", "icu_pattern/std", "icu_plurals/std", "icu_provider/std", "icu_locale_core/std"]

bench = []
Expand Down
10 changes: 5 additions & 5 deletions components/experimental/src/duration/duration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ impl Duration {
}

/// Describes whether a [`Duration`] is positive or negative.
#[derive(Debug, Default, Clone, PartialEq, Eq, PartialOrd, Ord)]
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
pub enum DurationSign {
#[default]
/// A positive duration.
Expand All @@ -72,10 +72,10 @@ pub enum DurationSign {
Negative,
}

impl DurationSign {
pub(crate) fn as_fixed_decimal_sign(&self) -> fixed_decimal::Sign {
match self {
DurationSign::Positive => fixed_decimal::Sign::Positive,
impl From<DurationSign> for fixed_decimal::Sign {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 that is good too.

fn from(sign: DurationSign) -> Self {
match sign {
DurationSign::Positive => fixed_decimal::Sign::None,
DurationSign::Negative => fixed_decimal::Sign::Negative,
}
}
Expand Down
Loading