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

Remove WeekDataV1 #5569

Merged
merged 2 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
29 changes: 0 additions & 29 deletions components/calendar/src/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ const _: () = {
impl_islamic_umm_al_qura_cache_v1_marker!(Baked);
impl_japanese_eras_v1_marker!(Baked);
impl_japanese_extended_eras_v1_marker!(Baked);
impl_week_data_v1_marker!(Baked);
impl_week_data_v2_marker!(Baked);
};

Expand All @@ -65,9 +64,6 @@ pub const MARKERS: &[DataMarkerInfo] = &[
JapaneseErasV1Marker::INFO,
JapaneseExtendedErasV1Marker::INFO,
WeekDataV2Marker::INFO,
// We include the duplicate data for now, as icu_datetime loads it directly
// https://github.com/unicode-org/icu4x/pull/4364#discussion_r1419877997
WeekDataV1Marker::INFO,
];

/// The date at which an era started
Expand Down Expand Up @@ -117,31 +113,6 @@ pub struct JapaneseErasV1<'data> {
pub dates_to_eras: ZeroVec<'data, (EraStartDate, TinyStr16)>,
}

/// An ICU4X mapping to a subset of CLDR weekData.
/// See CLDR-JSON's weekData.json for more context.
///
/// <div class="stab unstable">
/// 🚧 This code is considered unstable; it may change at any time, in breaking or non-breaking ways,
/// including in SemVer minor releases. While the serde representation of data structs is guaranteed
/// to be stable, their Rust representation might not be. Use with caution.
/// </div>
#[icu_provider::data_struct(marker(
WeekDataV1Marker,
"datetime/week_data@1",
fallback_by = "region"
))]
#[derive(Clone, Copy, Debug, PartialEq)]
#[cfg_attr(feature = "datagen", derive(serde::Serialize, databake::Bake))]
#[cfg_attr(feature = "datagen", databake(path = icu_calendar::provider))]
#[cfg_attr(feature = "serde", derive(serde::Deserialize))]
#[allow(clippy::exhaustive_structs)] // used in data provider
pub struct WeekDataV1 {
/// The first day of a week.
pub first_weekday: IsoWeekday,
/// For a given week, the minimum number of that week's days present in a given month or year for the week to be considered part of that month or year.
pub min_week_days: u8,
}

/// An ICU4X mapping to a subset of CLDR weekData.
/// See CLDR-JSON's weekData.json for more context.
///
Expand Down
74 changes: 8 additions & 66 deletions components/calendar/src/week_of.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,73 +25,15 @@ pub struct WeekCalculator {
pub weekend: Option<WeekdaySet>,
}

impl From<WeekDataV1> for WeekCalculator {
fn from(other: WeekDataV1) -> Self {
Self {
first_weekday: other.first_weekday,
min_week_days: other.min_week_days,
weekend: None,
}
}
}

impl From<&WeekDataV1> for WeekCalculator {
fn from(other: &WeekDataV1) -> Self {
Self {
first_weekday: other.first_weekday,
min_week_days: other.min_week_days,
weekend: None,
}
}
}

impl WeekCalculator {
/// Creates a new [`WeekCalculator`] from compiled data.
///
/// ✨ *Enabled with the `compiled_data` Cargo feature.*
///
/// [📚 Help choosing a constructor](icu_provider::constructors)
#[cfg(feature = "compiled_data")]
pub fn try_new(locale: &DataLocale) -> Result<Self, DataError> {
Self::try_new_unstable(&crate::provider::Baked, locale)
}

#[doc = icu_provider::gen_any_buffer_unstable_docs!(ANY, Self::try_new_unstable)]
pub fn try_new_with_any_provider(
provider: &(impl AnyProvider + ?Sized),
locale: &DataLocale,
) -> Result<Self, DataError> {
Self::try_new_unstable(&provider.as_downcasting(), locale).or_else(|e| {
DataProvider::<WeekDataV1Marker>::load(
&provider.as_downcasting(),
DataRequest {
id: DataIdentifierBorrowed::for_locale(locale),
..Default::default()
},
)
.map(|response| response.payload.get().into())
.map_err(|_| e)
})
}

#[cfg(feature = "serde")]
#[doc = icu_provider::gen_any_buffer_unstable_docs!(BUFFER, Self::try_new_unstable)]
pub fn try_new_with_buffer_provider(
provider: &(impl BufferProvider + ?Sized),
locale: &DataLocale,
) -> Result<Self, DataError> {
Self::try_new_unstable(&provider.as_deserializing(), locale).or_else(|e| {
DataProvider::<WeekDataV1Marker>::load(
&provider.as_deserializing(),
DataRequest {
id: DataIdentifierBorrowed::for_locale(locale),
..Default::default()
},
)
.map(|response| response.payload.get().into())
.map_err(|_| e)
})
}
icu_provider::gen_any_buffer_data_constructors!(
(locale) -> error: DataError,
/// Creates a new [`WeekCalculator`] from compiled data.
///
/// ✨ *Enabled with the `compiled_data` Cargo feature.*
///
/// [📚 Help choosing a constructor](icu_provider::constructors)
);

#[doc = icu_provider::gen_any_buffer_unstable_docs!(UNSTABLE, Self::try_new)]
pub fn try_new_unstable<P>(provider: &P, locale: &DataLocale) -> Result<Self, DataError>
Expand Down
1 change: 0 additions & 1 deletion components/icu/src/datagen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ fn test_markers_for_bin() {
crate::datetime::provider::neo::GregorianMonthNamesV1Marker::INFO,
crate::datetime::provider::neo::GregorianYearNamesV1Marker::INFO,
crate::datetime::provider::neo::WeekdayNamesV1Marker::INFO,
crate::calendar::provider::WeekDataV1Marker::INFO,
crate::calendar::provider::WeekDataV2Marker::INFO,
crate::decimal::provider::DecimalSymbolsV1Marker::INFO,
]
Expand Down
Binary file modified components/icu/tests/data/tutorial_buffer.wasm
Binary file not shown.
3 changes: 0 additions & 3 deletions provider/data/calendar/data/mod.rs

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

60 changes: 0 additions & 60 deletions provider/data/calendar/data/week_data_v1_marker.rs.data

This file was deleted.

117 changes: 0 additions & 117 deletions provider/data/calendar/fingerprints.csv
Original file line number Diff line number Diff line change
Expand Up @@ -4,123 +4,6 @@ calendar/islamicobservationalcache@1, <singleton>, 532B, 504B, 18af87d272c76f14
calendar/islamicummalquracache@1, <singleton>, 532B, 504B, ef6ac9ff14fd3f3
calendar/japanese@1, <singleton>, 134B, 111B, b31e52deaf52706f
calendar/japanext@1, <singleton>, 5238B, 5216B, 6c20e216c8cd6e41
datetime/week_data@1, <lookup>, 450B, 115 identifiers
datetime/week_data@1, <total>, 12B, 12B, 6 unique payloads
datetime/week_data@1, und, 2B, 2B, 62c3506f27376c25
datetime/week_data@1, und-AD, 2B, 2B, fb813f95ba4e1e31
datetime/week_data@1, und-AE, 2B, 2B, 4b008006948c4a31
datetime/week_data@1, und-AF, -> und-AE
datetime/week_data@1, und-AG, 2B, 2B, 636a8b37946c4ebf
datetime/week_data@1, und-AN, -> und-AD
datetime/week_data@1, und-AS, -> und-AG
datetime/week_data@1, und-AT, -> und-AD
datetime/week_data@1, und-AX, -> und-AD
datetime/week_data@1, und-BD, -> und-AG
datetime/week_data@1, und-BE, -> und-AD
datetime/week_data@1, und-BG, -> und-AD
datetime/week_data@1, und-BH, -> und-AE
datetime/week_data@1, und-BR, -> und-AG
datetime/week_data@1, und-BS, -> und-AG
datetime/week_data@1, und-BT, -> und-AG
datetime/week_data@1, und-BW, -> und-AG
datetime/week_data@1, und-BZ, -> und-AG
datetime/week_data@1, und-CA, -> und-AG
datetime/week_data@1, und-CH, -> und-AD
datetime/week_data@1, und-CO, -> und-AG
datetime/week_data@1, und-CZ, -> und-AD
datetime/week_data@1, und-DE, -> und-AD
datetime/week_data@1, und-DJ, -> und-AE
datetime/week_data@1, und-DK, -> und-AD
datetime/week_data@1, und-DM, -> und-AG
datetime/week_data@1, und-DO, -> und-AG
datetime/week_data@1, und-DZ, -> und-AE
datetime/week_data@1, und-EE, -> und-AD
datetime/week_data@1, und-EG, -> und-AE
datetime/week_data@1, und-ES, -> und-AD
datetime/week_data@1, und-ET, -> und-AG
datetime/week_data@1, und-FI, -> und-AD
datetime/week_data@1, und-FJ, -> und-AD
datetime/week_data@1, und-FO, -> und-AD
datetime/week_data@1, und-FR, -> und-AD
datetime/week_data@1, und-GB, -> und-AD
datetime/week_data@1, und-GF, -> und-AD
datetime/week_data@1, und-GG, -> und-AD
datetime/week_data@1, und-GI, -> und-AD
datetime/week_data@1, und-GP, -> und-AD
datetime/week_data@1, und-GR, -> und-AD
datetime/week_data@1, und-GT, -> und-AG
datetime/week_data@1, und-GU, -> und-AG
datetime/week_data@1, und-HK, -> und-AG
datetime/week_data@1, und-HN, -> und-AG
datetime/week_data@1, und-HU, -> und-AD
datetime/week_data@1, und-ID, -> und-AG
datetime/week_data@1, und-IE, -> und-AD
datetime/week_data@1, und-IL, -> und-AG
datetime/week_data@1, und-IM, -> und-AD
datetime/week_data@1, und-IN, -> und-AG
datetime/week_data@1, und-IQ, -> und-AE
datetime/week_data@1, und-IR, -> und-AE
datetime/week_data@1, und-IS, -> und-AD
datetime/week_data@1, und-IT, -> und-AD
datetime/week_data@1, und-JE, -> und-AD
datetime/week_data@1, und-JM, -> und-AG
datetime/week_data@1, und-JO, -> und-AE
datetime/week_data@1, und-JP, -> und-AG
datetime/week_data@1, und-KE, -> und-AG
datetime/week_data@1, und-KH, -> und-AG
datetime/week_data@1, und-KR, -> und-AG
datetime/week_data@1, und-KW, -> und-AE
datetime/week_data@1, und-LA, -> und-AG
datetime/week_data@1, und-LI, -> und-AD
datetime/week_data@1, und-LT, -> und-AD
datetime/week_data@1, und-LU, -> und-AD
datetime/week_data@1, und-LY, -> und-AE
datetime/week_data@1, und-MC, -> und-AD
datetime/week_data@1, und-MH, -> und-AG
datetime/week_data@1, und-MM, -> und-AG
datetime/week_data@1, und-MO, -> und-AG
datetime/week_data@1, und-MQ, -> und-AD
datetime/week_data@1, und-MT, -> und-AG
datetime/week_data@1, und-MV, 2B, 2B, 88f92c58a02b3795
datetime/week_data@1, und-MX, -> und-AG
datetime/week_data@1, und-MZ, -> und-AG
datetime/week_data@1, und-NI, -> und-AG
datetime/week_data@1, und-NL, -> und-AD
datetime/week_data@1, und-NO, -> und-AD
datetime/week_data@1, und-NP, -> und-AG
datetime/week_data@1, und-OM, -> und-AE
datetime/week_data@1, und-PA, -> und-AG
datetime/week_data@1, und-PE, -> und-AG
datetime/week_data@1, und-PH, -> und-AG
datetime/week_data@1, und-PK, -> und-AG
datetime/week_data@1, und-PL, -> und-AD
datetime/week_data@1, und-PR, -> und-AG
datetime/week_data@1, und-PT, 2B, 2B, c0c6146f812fb959
datetime/week_data@1, und-PY, -> und-AG
datetime/week_data@1, und-QA, -> und-AE
datetime/week_data@1, und-RE, -> und-AD
datetime/week_data@1, und-RU, -> und-AD
datetime/week_data@1, und-SA, -> und-AG
datetime/week_data@1, und-SD, -> und-AE
datetime/week_data@1, und-SE, -> und-AD
datetime/week_data@1, und-SG, -> und-AG
datetime/week_data@1, und-SJ, -> und-AD
datetime/week_data@1, und-SK, -> und-AD
datetime/week_data@1, und-SM, -> und-AD
datetime/week_data@1, und-SV, -> und-AG
datetime/week_data@1, und-SY, -> und-AE
datetime/week_data@1, und-TH, -> und-AG
datetime/week_data@1, und-TT, -> und-AG
datetime/week_data@1, und-TW, -> und-AG
datetime/week_data@1, und-UM, -> und-AG
datetime/week_data@1, und-US, -> und-AG
datetime/week_data@1, und-VA, -> und-AD
datetime/week_data@1, und-VE, -> und-AG
datetime/week_data@1, und-VI, -> und-AG
datetime/week_data@1, und-WS, -> und-AG
datetime/week_data@1, und-YE, -> und-AG
datetime/week_data@1, und-ZA, -> und-AG
datetime/week_data@1, und-ZW, -> und-AG
datetime/week_data@2, <lookup>, 450B, 115 identifiers
datetime/week_data@2, <total>, 33B, 33B, 11 unique payloads
datetime/week_data@2, und, 3B, 3B, 9d9f0d8d13520828
Expand Down
Loading