Skip to content

Commit 77cf05e

Browse files
committed
fix
1 parent d82a602 commit 77cf05e

File tree

2 files changed

+19
-30
lines changed

2 files changed

+19
-30
lines changed

components/calendar/src/cal/chinese.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,7 @@ impl Rules for China {
164164
)
165165
} else {
166166
// Currently local time is UTC+8
167-
simple_year_data(
168-
day_fraction_to_ms!(8 / 24),
169-
Default::default(),
170-
related_iso,
171-
)
167+
simple_year_data(day_fraction_to_ms!(8 / 24), Default::default(), related_iso)
172168
}
173169
}
174170

@@ -1065,8 +1061,7 @@ const MEAN_GREGORIAN_SOLAR_TERM_LENGTH: Milliseconds =
10651061
/// The mean synodic length on Jan 1 2000 according to the [Astronomical Almanac (1992)].
10661062
///
10671063
/// [Astronomical Almanac (1992)]: https://archive.org/details/131123ExplanatorySupplementAstronomicalAlmanac/page/n302/mode/1up
1068-
const MEAN_SYNODIC_MONTH_LENGTH: Milliseconds =
1069-
day_fraction_to_ms!(295305888531 / 10000000000i64);
1064+
const MEAN_SYNODIC_MONTH_LENGTH: Milliseconds = day_fraction_to_ms!(295305888531 / 10000000000i64);
10701065

10711066
/// Number of milliseconds in a day.
10721067
const MILLISECONDS_IN_EPHEMERIS_DAY: i64 = 24 * 60 * 60 * 1000;

provider/source/src/calendar/eras.rs

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -413,40 +413,34 @@ fn test_calendar_eras() {
413413
);
414414
}
415415

416-
if era.start.is_some() && calendar != "japanese" {
417-
assert_eq!(in_era.day_of_year().0, 1, "{calendar:?}");
418-
}
419-
420-
match in_era.year() {
421-
icu::calendar::types::YearInfo::Era(era_year) => {
422-
// Unless this is the first era and it's not an inverse era, check that the
423-
// not_in_era date is in a different era
424-
if idx != 0 || era.end.is_some() {
425-
assert_ne!(not_in_era.year().era().unwrap().era, era_year.era);
426-
}
416+
let icu::calendar::types::YearInfo::Era(era_year) = in_era.year() else {
417+
continue;
418+
};
427419

428-
// Check that the correct era code is returned
429-
if let Some(code) = era.code.as_deref() {
430-
assert_eq!(era_year.era, code);
431-
}
420+
// Unless this is the first era and it's not an inverse era, check that the
421+
// not_in_era date is in a different era
422+
if idx != 0 || era.end.is_some() {
423+
assert_ne!(not_in_era.year().era().unwrap().era, era_year.era);
424+
}
432425

433-
// Check that the start/end date uses year 1, and minimal/maximal month/day
434-
assert_eq!(era_year.year, 1, "Didn't get correct year for {in_era:?}");
435-
}
436-
// Cyclic calendars use related_iso for their extended years, which won't
437-
// work with the CLDR "default" eras. Skip testing them.
438-
icu::calendar::types::YearInfo::Cyclic(_) => (),
439-
_ => unreachable!(),
426+
// Check that the correct era code is returned
427+
if let Some(code) = era.code.as_deref() {
428+
assert_eq!(era_year.era, code);
440429
}
441430

431+
// Check that the start/end date uses year 1, and minimal/maximal month/day
432+
assert_eq!(era_year.year, 1, "Didn't get correct year for {in_era:?}");
433+
442434
if calendar == "japanese" {
443-
// Japanese is the only calendar that doesn't have its own months
435+
// Japanese is the only calendar that doesn't start eras on a new year
444436
} else if era.start.is_some() {
445437
assert_eq!(in_era.month().ordinal, 1);
446438
assert_eq!(in_era.day_of_month().0, 1);
439+
assert_eq!(in_era.day_of_year().0, 1);
447440
} else {
448441
assert_eq!(in_era.month().ordinal, in_era.months_in_year());
449442
assert_eq!(in_era.day_of_month().0, in_era.days_in_month());
443+
assert_eq!(in_era.day_of_year().0, in_era.days_in_year());
450444
}
451445
}
452446
}

0 commit comments

Comments
 (0)