Skip to content

Commit

Permalink
Rename modules to fieldsets::enums (#5836)
Browse files Browse the repository at this point in the history
<!--
Thank you for your pull request to ICU4X!

Reminder: try to use [Conventional
Comments](https://conventionalcomments.org/) to make comments clearer.

Please see
https://github.com/unicode-org/icu4x/blob/main/CONTRIBUTING.md for
general
information on contributing to ICU4X.
-->
  • Loading branch information
sffc authored Nov 19, 2024
1 parent 98e9aa8 commit 6410309
Show file tree
Hide file tree
Showing 34 changed files with 472 additions and 516 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ icu = "1.5.0"

```rust
use icu::calendar::DateTime;
use icu::datetime::{DateTimeFormatter, NeoSkeletonLength, fieldset::YMDT};
use icu::datetime::{DateTimeFormatter, NeoSkeletonLength, fieldsets::YMDT};
use icu::locale::locale;

let dtf = DateTimeFormatter::try_new(
Expand Down
8 changes: 4 additions & 4 deletions components/datetime/README.md

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

2 changes: 1 addition & 1 deletion components/datetime/benches/datetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
mod fixtures;

use criterion::{criterion_group, criterion_main, Criterion};
use icu_datetime::{fieldset::dynamic::CompositeFieldSet, FixedCalendarDateTimeFormatter};
use icu_datetime::{fieldsets::enums::CompositeFieldSet, FixedCalendarDateTimeFormatter};

use icu_calendar::{Date, DateTime, Gregorian, Time};
use icu_locale_core::Locale;
Expand Down
2 changes: 1 addition & 1 deletion components/datetime/benches/fixtures/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// called LICENSE at the top level of the ICU4X source tree
// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).

use icu_datetime::{fields::components, fieldset::serde::CompositeFieldSetSerde, options};
use icu_datetime::{fields::components, fieldsets::serde::CompositeFieldSetSerde, options};
use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
Expand Down
2 changes: 1 addition & 1 deletion components/datetime/examples/work_log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ icu_benchmark_macros::instrument!();
use icu_benchmark_macros::println;

use icu_calendar::DateTime;
use icu_datetime::{fieldset::YMDT, FixedCalendarDateTimeFormatter};
use icu_datetime::{fieldsets::YMDT, FixedCalendarDateTimeFormatter};
use icu_locale_core::locale;

const DATES_ISO: &[(i32, u8, u8, u8, u8, u8)] = &[
Expand Down
10 changes: 5 additions & 5 deletions components/datetime/src/combo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use crate::{provider::neo::*, scaffold::*};
/// Two ways to construct the same combo field set (in this case, weekday with location-based zone):
///
/// ```
/// use icu::datetime::fieldset::{Combo, E, L};
/// use icu::datetime::fieldsets::{Combo, E, L};
///
/// let field_set_1 = E::long().zone_l();
/// let field_set_2 = Combo::<E, L>::long();
Expand All @@ -26,7 +26,7 @@ use crate::{provider::neo::*, scaffold::*};
/// Format the weekday, hour, and location-based zone:
///
/// ```
/// use icu::datetime::fieldset::{Combo, ET, L};
/// use icu::datetime::fieldsets::{Combo, ET, L};
/// use icu::datetime::DateTimeFormatter;
/// use icu::locale::locale;
/// use icu::timezone::IxdtfParser;
Expand Down Expand Up @@ -54,7 +54,7 @@ use crate::{provider::neo::*, scaffold::*};
///
/// ```
/// use icu::calendar::Gregorian;
/// use icu::datetime::fieldset::{Combo, ET, L};
/// use icu::datetime::fieldsets::{Combo, ET, L};
/// use icu::datetime::FixedCalendarDateTimeFormatter;
/// use icu::locale::locale;
/// use icu::timezone::IxdtfParser;
Expand All @@ -79,11 +79,11 @@ use crate::{provider::neo::*, scaffold::*};
/// );
/// ```
///
/// Mix a dynamic [`DateFieldSet`](crate::fieldset::dynamic::DateFieldSet)
/// Mix a dynamic [`DateFieldSet`](crate::fieldsets::enums::DateFieldSet)
/// with a static time zone:
///
/// ```
/// use icu::datetime::fieldset::{Combo, YMD, Vs, dynamic::DateFieldSet};
/// use icu::datetime::fieldsets::{Combo, YMD, Vs, enums::DateFieldSet};
/// use icu::datetime::DateTimeFormatter;
/// use icu::locale::locale;
/// use icu::timezone::IxdtfParser;
Expand Down
86 changes: 43 additions & 43 deletions components/datetime/src/dynamic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,19 @@
//!
//! ```
//! use icu::calendar::DateTime;
//! use icu::datetime::fieldset;
//! use icu::datetime::fieldset::dynamic::CompositeDateTimeFieldSet;
//! use icu::datetime::fieldsets;
//! use icu::datetime::fieldsets::enums::CompositeDateTimeFieldSet;
//! use icu::datetime::DateTimeFormatter;
//! use icu::locale::locale;
//! use writeable::TryWriteable;
//!
//! fn get_field_set(should_display_time: bool) -> CompositeDateTimeFieldSet {
//! if should_display_time {
//! let field_set = fieldset::MDT::medium().hm();
//! CompositeDateTimeFieldSet::DateTime(fieldset::dynamic::DateAndTimeFieldSet::MDT(field_set))
//! let field_set = fieldsets::MDT::medium().hm();
//! CompositeDateTimeFieldSet::DateTime(fieldsets::enums::DateAndTimeFieldSet::MDT(field_set))
//! } else {
//! let field_set = fieldset::MD::medium();
//! CompositeDateTimeFieldSet::Date(fieldset::dynamic::DateFieldSet::MD(field_set))
//! let field_set = fieldsets::MD::medium();
//! CompositeDateTimeFieldSet::Date(fieldsets::enums::DateFieldSet::MD(field_set))
//! }
//! }
//!
Expand All @@ -57,9 +57,9 @@
//! assert_eq!(results, ["Jan 15, 4:00 PM", "Jan 15"])
//! ```

use crate::raw::neo::RawNeoOptions;
use crate::raw::neo::RawOptions;
use crate::scaffold::GetField;
use crate::{fields, fieldset, NeoSkeletonLength};
use crate::{fields, fieldsets, NeoSkeletonLength};
use icu_provider::prelude::*;

/// An enumeration over all possible date field sets.
Expand All @@ -68,25 +68,25 @@ use icu_provider::prelude::*;
pub enum DateFieldSet {
/// The day of the month, as in
/// “on the 1st”.
D(fieldset::D),
D(fieldsets::D),
/// The month and day of the month, as in
/// “January 1st”.
MD(fieldset::MD),
MD(fieldsets::MD),
/// The year, month, and day of the month, as in
/// “January 1st, 2000”.
YMD(fieldset::YMD),
YMD(fieldsets::YMD),
/// The day of the month and day of the week, as in
/// “Saturday 1st”.
DE(fieldset::DE),
DE(fieldsets::DE),
/// The month, day of the month, and day of the week, as in
/// “Saturday, January 1st”.
MDE(fieldset::MDE),
MDE(fieldsets::MDE),
/// The year, month, day of the month, and day of the week, as in
/// “Saturday, January 1st, 2000”.
YMDE(fieldset::YMDE),
YMDE(fieldsets::YMDE),
/// The day of the week alone, as in
/// “Saturday”.
E(fieldset::E),
E(fieldsets::E),
}

/// An enumeration over all possible calendar period field sets.
Expand All @@ -95,17 +95,17 @@ pub enum DateFieldSet {
pub enum CalendarPeriodFieldSet {
/// A standalone month, as in
/// “January”.
M(fieldset::M),
M(fieldsets::M),
/// A month and year, as in
/// “January 2000”.
YM(fieldset::YM),
YM(fieldsets::YM),
/// A year, as in
/// “2000”.
Y(fieldset::Y),
Y(fieldsets::Y),
// TODO: Add support for week-of-year
// /// The year and week of the year, as in
// /// “52nd week of 1999”.
// YW(fieldset::YW),
// YW(fieldsets::YW),
// TODO(#501): Consider adding support for Quarter and YearQuarter.
}

Expand All @@ -114,36 +114,36 @@ pub enum CalendarPeriodFieldSet {
#[non_exhaustive]
pub enum TimeFieldSet {
/// A time of day.
T(fieldset::T),
T(fieldsets::T),
}

/// An enumeration over all possible zone field sets.
///
/// Note: [`fieldset::Zs`] and [`fieldset::Vs`] are not included in this enum
/// Note: [`fieldsets::Zs`] and [`fieldsets::Vs`] are not included in this enum
/// because they are data size optimizations only.
///
/// # Time Zone Data Size
///
/// Time zone names contribute a lot of data size. For resource-constrained
/// environments, the following formats require the least amount of data:
///
/// - [`fieldset::Zs`]
/// - [`fieldset::O`]
/// - [`fieldsets::Zs`]
/// - [`fieldsets::O`]
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
#[non_exhaustive]
pub enum ZoneFieldSet {
/// The specific non-location format, as in
/// “Pacific Daylight Time”.
Z(fieldset::Z),
Z(fieldsets::Z),
/// The offset format, as in
/// “GMT−8”.
O(fieldset::O),
O(fieldsets::O),
/// The generic non-location format, as in
/// “Pacific Time”.
V(fieldset::V),
V(fieldsets::V),
/// The location format, as in
/// “Los Angeles time”.
L(fieldset::L),
L(fieldsets::L),
}

/// An enumeration over all possible zone styles.
Expand Down Expand Up @@ -173,25 +173,25 @@ pub enum ZoneStyle {
pub enum DateAndTimeFieldSet {
/// The day of the month with time of day, as in
/// “on the 1st at 10:31 AM”.
DT(fieldset::DT),
DT(fieldsets::DT),
/// The month and day of the month with time of day, as in
/// “January 1st at 10:31 AM”.
MDT(fieldset::MDT),
MDT(fieldsets::MDT),
/// The year, month, and day of the month with time of day, as in
/// “January 1st, 2000 at 10:31 AM”.
YMDT(fieldset::YMDT),
YMDT(fieldsets::YMDT),
/// The day of the month and day of the week with time of day, as in
/// “Saturday 1st at 10:31 AM”.
DET(fieldset::DET),
DET(fieldsets::DET),
/// The month, day of the month, and day of the week with time of day, as in
/// “Saturday, January 1st at 10:31 AM”.
MDET(fieldset::MDET),
MDET(fieldsets::MDET),
/// The year, month, day of the month, and day of the week with time of day, as in
/// “Saturday, January 1st, 2000 at 10:31 AM”.
YMDET(fieldset::YMDET),
YMDET(fieldsets::YMDET),
/// The day of the week alone with time of day, as in
/// “Saturday at 10:31 AM”.
ET(fieldset::ET),
ET(fieldsets::ET),
}

/// An enum supporting date, calendar period, time, and date+time field sets
Expand Down Expand Up @@ -296,7 +296,7 @@ macro_rules! impl_attrs {
/// # Examples
///
/// ```
#[doc = concat!("use icu::datetime::fieldset::dynamic::", stringify!($type), " as FS;")]
#[doc = concat!("use icu::datetime::fieldsets::enums::", stringify!($type), " as FS;")]
/// use icu_provider::DataMarkerAttributes;
///
/// assert!(FS::ALL_DATA_MARKER_ATTRIBUTES.contains(
Expand Down Expand Up @@ -324,7 +324,7 @@ macro_rules! impl_attrs {
};
(@to_raw_options, $type:path, [$($variant:ident),+,]) => {
impl $type {
pub(crate) fn to_raw_options(self) -> RawNeoOptions {
pub(crate) fn to_raw_options(self) -> RawOptions {
match self {
$(
Self::$variant(variant) => variant.to_raw_options(),
Expand Down Expand Up @@ -393,17 +393,17 @@ macro_rules! impl_attrs {
Self::$variant(variant) => (variant.length, variant.time_precision, variant.alignment),
)+
};
TimeFieldSet::T(fieldset::T {
TimeFieldSet::T(fieldsets::T {
length,
time_precision,
alignment,
})
}
#[cfg(all(feature = "serde", feature = "experimental"))]
pub(crate) fn from_date_field_set_with_raw_options(date_field_set: DateFieldSet, options: RawNeoOptions) -> Self {
pub(crate) fn from_date_field_set_with_raw_options(date_field_set: DateFieldSet, options: RawOptions) -> Self {
match date_field_set {
$(
DateFieldSet::$d_variant(_) => Self::$variant(fieldset::$variant::from_raw_options(options)),
DateFieldSet::$d_variant(_) => Self::$variant(fieldsets::$variant::from_raw_options(options)),
)+
}
}
Expand Down Expand Up @@ -476,10 +476,10 @@ impl ZoneFieldSet {
length: NeoSkeletonLength,
) -> Self {
match style {
ZoneStyle::Z => Self::Z(fieldset::Z::with_length(length)),
ZoneStyle::O => Self::O(fieldset::O::with_length(length)),
ZoneStyle::V => Self::V(fieldset::V::with_length(length)),
ZoneStyle::L => Self::L(fieldset::L::with_length(length)),
ZoneStyle::Z => Self::Z(fieldsets::Z::with_length(length)),
ZoneStyle::O => Self::O(fieldsets::O::with_length(length)),
ZoneStyle::V => Self::V(fieldsets::V::with_length(length)),
ZoneStyle::L => Self::L(fieldsets::L::with_length(length)),
}
}
}
Expand Down
Loading

0 comments on commit 6410309

Please sign in to comment.