Skip to content

Commit

Permalink
Merge branch 'main' into strict-tzinfo-2
Browse files Browse the repository at this point in the history
  • Loading branch information
sffc authored Oct 17, 2024
2 parents e370305 + 058bf81 commit e792014
Show file tree
Hide file tree
Showing 82 changed files with 689 additions and 840 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- General
- 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)
- `icu_collections`
- `icu_normalizer`
- `icu_datetime`
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ let dtf = NeoFormatter::try_new(
)
.expect("locale should be present in compiled data");

let date = DateTime::try_new_iso_datetime(2020, 9, 12, 12, 35, 0).expect("datetime should be valid");
let date = DateTime::try_new_iso(2020, 9, 12, 12, 35, 0).expect("datetime should be valid");
let date = date.to_any();

let formatted_date = dtf.convert_and_format(&date).to_string_lossy();
Expand Down
6 changes: 3 additions & 3 deletions components/calendar/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/calendar/benches/convert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ fn bench_calendar<C: Clone + Calendar>(
name: &str,
calendar: C,
) {
let iso = Date::try_new_iso_date(2023, 8, 16).unwrap();
let iso = Date::try_new_iso(2023, 8, 16).unwrap();
group.bench_function(name, |b| {
b.iter(|| {
let converted = black_box(iso).to_calendar(Ref(&calendar));
Expand Down
46 changes: 20 additions & 26 deletions components/calendar/benches/date.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ fn bench_calendar<C: Clone + Calendar>(
let mut instantiated_date_calendar = calendar_date_init(fx.year, fx.month, fx.day);

// Conversion from ISO
let date_iso = Date::try_new_iso_date(fx.year, fx.month, fx.day).unwrap();
let date_iso = Date::try_new_iso(fx.year, fx.month, fx.day).unwrap();
let mut converted_date_calendar = Date::new_from_iso(date_iso, calendar.clone());

bench_date(&mut instantiated_date_calendar);
Expand All @@ -62,7 +62,7 @@ fn date_benches(c: &mut Criterion) {
"calendar/overview",
&fxs,
icu::calendar::iso::Iso,
|y, m, d| Date::try_new_iso_date(y, m, d).unwrap(),
|y, m, d| Date::try_new_iso(y, m, d).unwrap(),
);

#[cfg(feature = "bench")]
Expand All @@ -71,7 +71,7 @@ fn date_benches(c: &mut Criterion) {
"calendar/buddhist",
&fxs,
icu::calendar::buddhist::Buddhist,
|y, m, d| Date::try_new_buddhist_date(y, m, d).unwrap(),
|y, m, d| Date::try_new_buddhist(y, m, d).unwrap(),
);

#[cfg(feature = "bench")]
Expand All @@ -80,7 +80,7 @@ fn date_benches(c: &mut Criterion) {
"calendar/coptic",
&fxs,
icu::calendar::coptic::Coptic,
|y, m, d| Date::try_new_coptic_date(y, m, d).unwrap(),
|y, m, d| Date::try_new_coptic(y, m, d).unwrap(),
);

#[cfg(feature = "bench")]
Expand All @@ -90,7 +90,7 @@ fn date_benches(c: &mut Criterion) {
&fxs,
icu::calendar::ethiopian::Ethiopian::new(),
|y, m, d| {
Date::try_new_ethiopian_date(
Date::try_new_ethiopian(
icu::calendar::ethiopian::EthiopianEraStyle::AmeteMihret,
y,
m,
Expand All @@ -106,7 +106,7 @@ fn date_benches(c: &mut Criterion) {
"calendar/indian",
&fxs,
icu::calendar::indian::Indian,
|y, m, d| Date::try_new_indian_date(y, m, d).unwrap(),
|y, m, d| Date::try_new_indian(y, m, d).unwrap(),
);

#[cfg(feature = "bench")]
Expand All @@ -115,7 +115,7 @@ fn date_benches(c: &mut Criterion) {
"calendar/persian",
&fxs,
icu::calendar::persian::Persian,
|y, m, d| Date::try_new_persian_date(y, m, d).unwrap(),
|y, m, d| Date::try_new_persian(y, m, d).unwrap(),
);

#[cfg(feature = "bench")]
Expand All @@ -124,7 +124,7 @@ fn date_benches(c: &mut Criterion) {
"calendar/roc",
&fxs,
icu::calendar::roc::Roc,
|y, m, d| Date::try_new_roc_date(y, m, d).unwrap(),
|y, m, d| Date::try_new_roc(y, m, d).unwrap(),
);

#[cfg(feature = "bench")]
Expand All @@ -133,7 +133,7 @@ fn date_benches(c: &mut Criterion) {
"calendar/julian",
&fxs,
icu::calendar::julian::Julian,
|y, m, d| Date::try_new_julian_date(y, m, d).unwrap(),
|y, m, d| Date::try_new_julian(y, m, d).unwrap(),
);

#[cfg(feature = "bench")]
Expand All @@ -143,7 +143,7 @@ fn date_benches(c: &mut Criterion) {
&fxs,
icu::calendar::chinese::Chinese::new_always_calculating(),
|y, m, d| {
Date::try_new_chinese_date_with_calendar(
Date::try_new_chinese_with_calendar(
y,
m,
d,
Expand All @@ -160,13 +160,8 @@ fn date_benches(c: &mut Criterion) {
&fxs,
icu::calendar::chinese::Chinese::new(),
|y, m, d| {
Date::try_new_chinese_date_with_calendar(
y,
m,
d,
icu::calendar::chinese::Chinese::new(),
)
.unwrap()
Date::try_new_chinese_with_calendar(y, m, d, icu::calendar::chinese::Chinese::new())
.unwrap()
},
);

Expand All @@ -177,7 +172,7 @@ fn date_benches(c: &mut Criterion) {
&fxs,
icu::calendar::dangi::Dangi::new_always_calculating(),
|y, m, d| {
Date::try_new_dangi_date_with_calendar(
Date::try_new_dangi_with_calendar(
y,
m,
d,
Expand All @@ -194,8 +189,7 @@ fn date_benches(c: &mut Criterion) {
&fxs,
icu::calendar::dangi::Dangi::new(),
|y, m, d| {
Date::try_new_dangi_date_with_calendar(y, m, d, icu::calendar::dangi::Dangi::new())
.unwrap()
Date::try_new_dangi_with_calendar(y, m, d, icu::calendar::dangi::Dangi::new()).unwrap()
},
);

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

#[cfg(feature = "bench")]
Expand All @@ -214,7 +208,7 @@ fn date_benches(c: &mut Criterion) {
"calendar/gregorian",
&fxs,
icu::calendar::gregorian::Gregorian,
|y, m, d| Date::try_new_gregorian_date(y, m, d).unwrap(),
|y, m, d| Date::try_new_gregorian(y, m, d).unwrap(),
);

#[cfg(feature = "bench")]
Expand All @@ -224,7 +218,7 @@ fn date_benches(c: &mut Criterion) {
&fxs,
icu::calendar::islamic::IslamicCivil::new(),
|y, m, d| {
Date::try_new_islamic_civil_date_with_calendar(
Date::try_new_islamic_civil_with_calendar(
y,
m,
d,
Expand All @@ -241,7 +235,7 @@ fn date_benches(c: &mut Criterion) {
&fxs,
icu::calendar::islamic::IslamicTabular::new(),
|y, m, d| {
Date::try_new_islamic_tabular_date_with_calendar(
Date::try_new_islamic_tabular_with_calendar(
y,
m,
d,
Expand All @@ -258,7 +252,7 @@ fn date_benches(c: &mut Criterion) {
&fxs,
icu::calendar::islamic::IslamicUmmAlQura::new_always_calculating(),
|y, m, d| {
Date::try_new_ummalqura_date(
Date::try_new_ummalqura_with_calendar(
y,
m,
d,
Expand All @@ -275,7 +269,7 @@ fn date_benches(c: &mut Criterion) {
&fxs,
icu::calendar::islamic::IslamicObservational::new_always_calculating(),
|y, m, d| {
Date::try_new_observational_islamic_date(
Date::try_new_observational_islamic_with_calendar(
y,
m,
d,
Expand Down
33 changes: 16 additions & 17 deletions components/calendar/benches/datetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,9 @@ fn bench_calendar<C: Clone + Calendar>(
);

// Conversion from ISO
let datetime_iso = DateTime::try_new_iso_datetime(
fx.year, fx.month, fx.day, fx.hour, fx.minute, fx.second,
)
.unwrap();
let datetime_iso =
DateTime::try_new_iso(fx.year, fx.month, fx.day, fx.hour, fx.minute, fx.second)
.unwrap();
let mut converted_datetime_calendar =
DateTime::new_from_iso(datetime_iso, calendar.clone());

Expand All @@ -73,7 +72,7 @@ fn datetime_benches(c: &mut Criterion) {
"calendar/overview",
&fxs,
icu::calendar::iso::Iso,
|y, m, d, h, min, s| DateTime::try_new_iso_datetime(y, m, d, h, min, s).unwrap(),
|y, m, d, h, min, s| DateTime::try_new_iso(y, m, d, h, min, s).unwrap(),
);

#[cfg(feature = "bench")]
Expand All @@ -82,7 +81,7 @@ fn datetime_benches(c: &mut Criterion) {
"calendar/buddhist",
&fxs,
icu::calendar::buddhist::Buddhist,
|y, m, d, h, min, s| DateTime::try_new_buddhist_datetime(y, m, d, h, min, s).unwrap(),
|y, m, d, h, min, s| DateTime::try_new_buddhist(y, m, d, h, min, s).unwrap(),
);

#[cfg(feature = "bench")]
Expand All @@ -91,7 +90,7 @@ fn datetime_benches(c: &mut Criterion) {
"calendar/coptic",
&fxs,
icu::calendar::coptic::Coptic,
|y, m, d, h, min, s| DateTime::try_new_coptic_datetime(y, m, d, h, min, s).unwrap(),
|y, m, d, h, min, s| DateTime::try_new_coptic(y, m, d, h, min, s).unwrap(),
);

#[cfg(feature = "bench")]
Expand All @@ -101,7 +100,7 @@ fn datetime_benches(c: &mut Criterion) {
&fxs,
icu::calendar::ethiopian::Ethiopian::new(),
|y, m, d, h, min, s| {
DateTime::try_new_ethiopian_datetime(
DateTime::try_new_ethiopian(
icu::calendar::ethiopian::EthiopianEraStyle::AmeteMihret,
y,
m,
Expand All @@ -121,7 +120,7 @@ fn datetime_benches(c: &mut Criterion) {
&fxs,
icu::calendar::chinese::Chinese::new_always_calculating(),
|y, m, d, h, min, s| {
DateTime::try_new_chinese_datetime_with_calendar(
DateTime::try_new_chinese_with_calendar(
y,
m,
d,
Expand All @@ -141,7 +140,7 @@ fn datetime_benches(c: &mut Criterion) {
&fxs,
icu::calendar::chinese::Chinese::new(),
|y, m, d, h, min, s| {
DateTime::try_new_chinese_datetime_with_calendar(
DateTime::try_new_chinese_with_calendar(
y,
m,
d,
Expand All @@ -160,7 +159,7 @@ fn datetime_benches(c: &mut Criterion) {
"calendar/gregorian",
&fxs,
icu::calendar::gregorian::Gregorian,
|y, m, d, h, min, s| DateTime::try_new_gregorian_datetime(y, m, d, h, min, s).unwrap(),
|y, m, d, h, min, s| DateTime::try_new_gregorian(y, m, d, h, min, s).unwrap(),
);

#[cfg(feature = "bench")]
Expand All @@ -169,7 +168,7 @@ fn datetime_benches(c: &mut Criterion) {
"calendar/indian",
&fxs,
icu::calendar::indian::Indian,
|y, m, d, h, min, s| DateTime::try_new_indian_datetime(y, m, d, h, min, s).unwrap(),
|y, m, d, h, min, s| DateTime::try_new_indian(y, m, d, h, min, s).unwrap(),
);

#[cfg(feature = "bench")]
Expand All @@ -178,7 +177,7 @@ fn datetime_benches(c: &mut Criterion) {
"calendar/julian",
&fxs,
icu::calendar::julian::Julian,
|y, m, d, h, min, s| DateTime::try_new_julian_datetime(y, m, d, h, min, s).unwrap(),
|y, m, d, h, min, s| DateTime::try_new_julian(y, m, d, h, min, s).unwrap(),
);

#[cfg(feature = "bench")]
Expand All @@ -188,7 +187,7 @@ fn datetime_benches(c: &mut Criterion) {
&fxs,
icu::calendar::islamic::IslamicCivil::new(),
|y, m, d, h, min, s| {
DateTime::try_new_islamic_civil_datetime_with_calendar(
DateTime::try_new_islamic_civil_with_calendar(
y,
m,
d,
Expand All @@ -208,7 +207,7 @@ fn datetime_benches(c: &mut Criterion) {
&fxs,
icu::calendar::islamic::IslamicTabular::new(),
|y, m, d, h, min, s| {
DateTime::try_new_islamic_tabular_datetime_with_calendar(
DateTime::try_new_islamic_tabular_with_calendar(
y,
m,
d,
Expand All @@ -228,7 +227,7 @@ fn datetime_benches(c: &mut Criterion) {
&fxs,
icu::calendar::islamic::IslamicUmmAlQura::new_always_calculating(),
|y, m, d, h, min, s| {
DateTime::try_new_ummalqura_datetime(
DateTime::try_new_ummalqura_with_calendar(
y,
m,
d,
Expand All @@ -248,7 +247,7 @@ fn datetime_benches(c: &mut Criterion) {
&fxs,
icu::calendar::islamic::IslamicObservational::new_always_calculating(),
|y, m, d, h, min, s| {
DateTime::try_new_observational_islamic_datetime(
DateTime::try_new_observational_islamic_with_calendar(
y,
m,
d,
Expand Down
2 changes: 1 addition & 1 deletion components/calendar/examples/iso_date_manipulations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const DATES_ISO: &[(i32, u8, u8)] = &[

fn main() {
for &(year, month, day) in DATES_ISO {
let date = Date::try_new_iso_date(year, month, day).expect("date should parse");
let date = Date::try_new_iso(year, month, day).expect("date should parse");
println!(
"Year: {}, Month: {}, Day: {}",
date.year().era_year_or_extended(),
Expand Down
2 changes: 1 addition & 1 deletion components/calendar/examples/iso_datetime_manipulations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const DATETIMES_ISO: &[(i32, u8, u8, u8, u8, u8)] = &[

fn main() {
for &(year, month, day, hour, minute, second) in DATETIMES_ISO {
let datetime = DateTime::try_new_iso_datetime(year, month, day, hour, minute, second)
let datetime = DateTime::try_new_iso(year, month, day, hour, minute, second)
.expect("datetime should parse");
println!(
"Year: {}, Month: {}, Day: {}, Hour: {}, Minute: {}, Second: {}",
Expand Down
4 changes: 2 additions & 2 deletions components/calendar/src/any_calendar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ use core::fmt;
///
///
/// // construct another datetime by converting from ISO
/// let iso_datetime = DateTime::try_new_iso_datetime(2020, 9, 1, 12, 34, 28)
/// let iso_datetime = DateTime::try_new_iso(2020, 9, 1, 12, 34, 28)
/// .expect("Failed to construct ISO DateTime.");
/// let iso_converted = iso_datetime.to_calendar(calendar);
///
/// // Construct a datetime in the appropriate typed calendar and convert
/// let japanese_calendar = Japanese::new();
/// let japanese_datetime = DateTime::try_new_japanese_datetime(Era(tinystr!(16, "heisei")), 15, 3, 28,
/// let japanese_datetime = DateTime::try_new_japanese_with_calendar(Era(tinystr!(16, "heisei")), 15, 3, 28,
/// 12, 33, 12, japanese_calendar).unwrap();
/// // This is a DateTime<AnyCalendar>
/// let any_japanese_datetime = japanese_datetime.to_any();
Expand Down
Loading

0 comments on commit e792014

Please sign in to comment.