Skip to content

Commit

Permalink
Restructure icu_calendar public API to put all calendars under cal (#…
Browse files Browse the repository at this point in the history
…5701)

Fixes #5632



<!--
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
Manishearth authored Oct 18, 2024
1 parent 2873b0e commit 85e83d6
Show file tree
Hide file tree
Showing 25 changed files with 185 additions and 167 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- Compiled data updated to CLDR 45 and ICU 75 (unicode-org#4782)
- `icu_calendar`
- Consistently name calendar-specific `Date`/`DateTime` functions that have a calendar argument (https://github.com/unicode-org/icu4x/pull/5692)
- Move all calendar types to `cal` module (https://github.com/unicode-org/icu4x/pull/5701)
- `icu_collections`
- `icu_normalizer`
- `icu_datetime`
Expand Down
8 changes: 4 additions & 4 deletions components/calendar/README.md

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

28 changes: 14 additions & 14 deletions components/calendar/benches/convert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,81 +29,81 @@ fn bench_calendar<C: Clone + Calendar>(
fn convert_benches(c: &mut Criterion) {
let mut group = c.benchmark_group("convert");

bench_calendar(&mut group, "calendar/iso", icu::calendar::iso::Iso);
bench_calendar(&mut group, "calendar/iso", icu::calendar::cal::Iso);

#[cfg(feature = "bench")]
bench_calendar(
&mut group,
"calendar/buddhist",
icu::calendar::buddhist::Buddhist,
icu::calendar::cal::Buddhist,
);

#[cfg(feature = "bench")]
bench_calendar(&mut group, "calendar/coptic", icu::calendar::coptic::Coptic);
bench_calendar(&mut group, "calendar/coptic", icu::calendar::cal::Coptic);

#[cfg(feature = "bench")]
bench_calendar(
&mut group,
"calendar/ethiopic",
icu::calendar::ethiopian::Ethiopian::new(),
icu::calendar::cal::Ethiopian::new(),
);

#[cfg(feature = "bench")]
bench_calendar(&mut group, "calendar/indian", icu::calendar::indian::Indian);
bench_calendar(&mut group, "calendar/indian", icu::calendar::cal::Indian);

#[cfg(feature = "bench")]
bench_calendar(&mut group, "calendar/julian", icu::calendar::julian::Julian);
bench_calendar(&mut group, "calendar/julian", icu::calendar::cal::Julian);

#[cfg(feature = "bench")]
bench_calendar(
&mut group,
"calendar/chinese_calculating",
icu::calendar::chinese::Chinese::new_always_calculating(),
icu::calendar::cal::Chinese::new_always_calculating(),
);

#[cfg(feature = "bench")]
bench_calendar(
&mut group,
"calendar/chinese_cached",
icu::calendar::chinese::Chinese::new(),
icu::calendar::cal::Chinese::new(),
);

#[cfg(feature = "bench")]
bench_calendar(
&mut group,
"calendar/gregorian",
icu::calendar::gregorian::Gregorian,
icu::calendar::cal::Gregorian,
);

#[cfg(feature = "bench")]
bench_calendar(&mut group, "calendar/hebrew", icu::calendar::hebrew::Hebrew);
bench_calendar(&mut group, "calendar/hebrew", icu::calendar::cal::Hebrew);

#[cfg(feature = "bench")]
bench_calendar(
&mut group,
"calendar/islamic/observational",
icu::calendar::islamic::IslamicObservational::new_always_calculating(),
icu::calendar::cal::IslamicObservational::new_always_calculating(),
);

#[cfg(feature = "bench")]
bench_calendar(
&mut group,
"calendar/islamic/civil",
icu::calendar::islamic::IslamicCivil::new(),
icu::calendar::cal::IslamicCivil::new(),
);

#[cfg(feature = "bench")]
bench_calendar(
&mut group,
"calendar/islamic/ummalqura",
icu::calendar::islamic::IslamicUmmAlQura::new_always_calculating(),
icu::calendar::cal::IslamicUmmAlQura::new_always_calculating(),
);

#[cfg(feature = "bench")]
bench_calendar(
&mut group,
"calendar/islamic/tabular",
icu::calendar::islamic::IslamicTabular::new(),
icu::calendar::cal::IslamicTabular::new(),
);

group.finish();
Expand Down
61 changes: 28 additions & 33 deletions components/calendar/benches/date.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ fn date_benches(c: &mut Criterion) {
&mut group,
"calendar/overview",
&fxs,
icu::calendar::iso::Iso,
icu::calendar::cal::Iso,
|y, m, d| Date::try_new_iso(y, m, d).unwrap(),
);

Expand All @@ -70,7 +70,7 @@ fn date_benches(c: &mut Criterion) {
&mut group,
"calendar/buddhist",
&fxs,
icu::calendar::buddhist::Buddhist,
icu::calendar::cal::Buddhist,
|y, m, d| Date::try_new_buddhist(y, m, d).unwrap(),
);

Expand All @@ -79,7 +79,7 @@ fn date_benches(c: &mut Criterion) {
&mut group,
"calendar/coptic",
&fxs,
icu::calendar::coptic::Coptic,
icu::calendar::cal::Coptic,
|y, m, d| Date::try_new_coptic(y, m, d).unwrap(),
);

Expand All @@ -88,15 +88,10 @@ fn date_benches(c: &mut Criterion) {
&mut group,
"calendar/ethiopic",
&fxs,
icu::calendar::ethiopian::Ethiopian::new(),
icu::calendar::cal::Ethiopian::new(),
|y, m, d| {
Date::try_new_ethiopian(
icu::calendar::ethiopian::EthiopianEraStyle::AmeteMihret,
y,
m,
d,
)
.unwrap()
Date::try_new_ethiopian(icu::calendar::cal::EthiopianEraStyle::AmeteMihret, y, m, d)
.unwrap()
},
);

Expand All @@ -105,7 +100,7 @@ fn date_benches(c: &mut Criterion) {
&mut group,
"calendar/indian",
&fxs,
icu::calendar::indian::Indian,
icu::calendar::cal::Indian,
|y, m, d| Date::try_new_indian(y, m, d).unwrap(),
);

Expand All @@ -114,7 +109,7 @@ fn date_benches(c: &mut Criterion) {
&mut group,
"calendar/persian",
&fxs,
icu::calendar::persian::Persian,
icu::calendar::cal::Persian,
|y, m, d| Date::try_new_persian(y, m, d).unwrap(),
);

Expand All @@ -123,7 +118,7 @@ fn date_benches(c: &mut Criterion) {
&mut group,
"calendar/roc",
&fxs,
icu::calendar::roc::Roc,
icu::calendar::cal::Roc,
|y, m, d| Date::try_new_roc(y, m, d).unwrap(),
);

Expand All @@ -132,7 +127,7 @@ fn date_benches(c: &mut Criterion) {
&mut group,
"calendar/julian",
&fxs,
icu::calendar::julian::Julian,
icu::calendar::cal::Julian,
|y, m, d| Date::try_new_julian(y, m, d).unwrap(),
);

Expand All @@ -141,13 +136,13 @@ fn date_benches(c: &mut Criterion) {
&mut group,
"calendar/chinese_calculating",
&fxs,
icu::calendar::chinese::Chinese::new_always_calculating(),
icu::calendar::cal::Chinese::new_always_calculating(),
|y, m, d| {
Date::try_new_chinese_with_calendar(
y,
m,
d,
icu::calendar::chinese::Chinese::new_always_calculating(),
icu::calendar::cal::Chinese::new_always_calculating(),
)
.unwrap()
},
Expand All @@ -158,9 +153,9 @@ fn date_benches(c: &mut Criterion) {
&mut group,
"calendar/chinese_cached",
&fxs,
icu::calendar::chinese::Chinese::new(),
icu::calendar::cal::Chinese::new(),
|y, m, d| {
Date::try_new_chinese_with_calendar(y, m, d, icu::calendar::chinese::Chinese::new())
Date::try_new_chinese_with_calendar(y, m, d, icu::calendar::cal::Chinese::new())
.unwrap()
},
);
Expand All @@ -170,13 +165,13 @@ fn date_benches(c: &mut Criterion) {
&mut group,
"calendar/dangi_calculating",
&fxs,
icu::calendar::dangi::Dangi::new_always_calculating(),
icu::calendar::cal::Dangi::new_always_calculating(),
|y, m, d| {
Date::try_new_dangi_with_calendar(
y,
m,
d,
icu::calendar::dangi::Dangi::new_always_calculating(),
icu::calendar::cal::Dangi::new_always_calculating(),
)
.unwrap()
},
Expand All @@ -187,9 +182,9 @@ fn date_benches(c: &mut Criterion) {
&mut group,
"calendar/dangi_cached",
&fxs,
icu::calendar::dangi::Dangi::new(),
icu::calendar::cal::Dangi::new(),
|y, m, d| {
Date::try_new_dangi_with_calendar(y, m, d, icu::calendar::dangi::Dangi::new()).unwrap()
Date::try_new_dangi_with_calendar(y, m, d, icu::calendar::cal::Dangi::new()).unwrap()
},
);

Expand All @@ -198,7 +193,7 @@ fn date_benches(c: &mut Criterion) {
&mut group,
"calendar/hebrew",
&fxs,
icu::calendar::hebrew::Hebrew,
icu::calendar::cal::Hebrew,
|y, m, d| Date::try_new_hebrew(y, m, d).unwrap(),
);

Expand All @@ -207,7 +202,7 @@ fn date_benches(c: &mut Criterion) {
&mut group,
"calendar/gregorian",
&fxs,
icu::calendar::gregorian::Gregorian,
icu::calendar::cal::Gregorian,
|y, m, d| Date::try_new_gregorian(y, m, d).unwrap(),
);

Expand All @@ -216,13 +211,13 @@ fn date_benches(c: &mut Criterion) {
&mut group,
"calendar/islamic/civil",
&fxs,
icu::calendar::islamic::IslamicCivil::new(),
icu::calendar::cal::IslamicCivil::new(),
|y, m, d| {
Date::try_new_islamic_civil_with_calendar(
y,
m,
d,
icu::calendar::islamic::IslamicCivil::new(),
icu::calendar::cal::IslamicCivil::new(),
)
.unwrap()
},
Expand All @@ -233,13 +228,13 @@ fn date_benches(c: &mut Criterion) {
&mut group,
"calendar/islamic/tabular",
&fxs,
icu::calendar::islamic::IslamicTabular::new(),
icu::calendar::cal::IslamicTabular::new(),
|y, m, d| {
Date::try_new_islamic_tabular_with_calendar(
y,
m,
d,
icu::calendar::islamic::IslamicTabular::new(),
icu::calendar::cal::IslamicTabular::new(),
)
.unwrap()
},
Expand All @@ -250,13 +245,13 @@ fn date_benches(c: &mut Criterion) {
&mut group,
"calendar/islamic/ummalqura",
&fxs,
icu::calendar::islamic::IslamicUmmAlQura::new_always_calculating(),
icu::calendar::cal::IslamicUmmAlQura::new_always_calculating(),
|y, m, d| {
Date::try_new_ummalqura_with_calendar(
y,
m,
d,
icu::calendar::islamic::IslamicUmmAlQura::new_always_calculating(),
icu::calendar::cal::IslamicUmmAlQura::new_always_calculating(),
)
.unwrap()
},
Expand All @@ -267,13 +262,13 @@ fn date_benches(c: &mut Criterion) {
&mut group,
"calendar/islamic/observational",
&fxs,
icu::calendar::islamic::IslamicObservational::new_always_calculating(),
icu::calendar::cal::IslamicObservational::new_always_calculating(),
|y, m, d| {
Date::try_new_observational_islamic_with_calendar(
y,
m,
d,
icu::calendar::islamic::IslamicObservational::new_always_calculating(),
icu::calendar::cal::IslamicObservational::new_always_calculating(),
)
.unwrap()
},
Expand Down
Loading

0 comments on commit 85e83d6

Please sign in to comment.