Skip to content

Commit 81161a7

Browse files
committed
era indices
1 parent 5670b23 commit 81161a7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+949
-1545
lines changed

components/calendar/src/any_calendar.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1584,14 +1584,14 @@ mod tests {
15841584
fn japanese() {
15851585
let japanese = AnyCalendar::new(AnyCalendarKind::Japanese);
15861586
let japanese = Ref(&japanese);
1587-
single_test_roundtrip(japanese, Some(("reiwa", None)), 3, Month::new(3), 1);
1588-
single_test_roundtrip(japanese, Some(("heisei", None)), 6, Month::new(12), 1);
1589-
single_test_roundtrip(japanese, Some(("meiji", None)), 10, Month::new(3), 1);
1590-
single_test_roundtrip(japanese, Some(("ce", None)), 1000, Month::new(3), 1);
1587+
single_test_roundtrip(japanese, Some(("reiwa", Some(6))), 3, Month::new(3), 1);
1588+
single_test_roundtrip(japanese, Some(("heisei", Some(5))), 6, Month::new(12), 1);
1589+
single_test_roundtrip(japanese, Some(("meiji", Some(2))), 10, Month::new(3), 1);
1590+
single_test_roundtrip(japanese, Some(("ce", Some(1))), 1000, Month::new(3), 1);
15911591
single_test_roundtrip(japanese, None, 1000, Month::new(3), 1);
15921592
single_test_roundtrip(japanese, None, -100, Month::new(3), 1);
15931593
single_test_roundtrip(japanese, None, 2024, Month::new(3), 1);
1594-
single_test_roundtrip(japanese, Some(("bce", None)), 10, Month::new(3), 1);
1594+
single_test_roundtrip(japanese, Some(("bce", Some(0))), 10, Month::new(3), 1);
15951595
// Since #6910, the era range is not enforced in try_from_codes
15961596
/*
15971597
single_test_error(

components/calendar/src/cal/japanese.rs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -200,24 +200,27 @@ impl GregorianYears for &'_ Japanese {
200200
fn era_year_from_extended(&self, year: i32, month: u8, day: u8) -> types::EraYear {
201201
let date: EraStartDate = EraStartDate { year, month, day };
202202

203-
if let Some((start, era)) = [self.last_era.expand(), REIWA, HEISEI, SHOWA, TAISHO, MEIJI]
204-
.into_iter()
205-
.find(|&(start, _)| date >= start && year >= 1873)
203+
if let Some((idx, (start, era))) = [
204+
(7, self.last_era.expand()),
205+
(6, REIWA),
206+
(5, HEISEI),
207+
(4, SHOWA),
208+
(3, TAISHO),
209+
(2, MEIJI),
210+
]
211+
.into_iter()
212+
.skip((self.last_era.year == 0) as usize)
213+
.find(|&(_, (start, _))| date >= start && year >= 1873)
206214
{
207215
types::EraYear {
208216
era,
209-
// TODO: return era indices?
210-
era_index: None,
217+
era_index: Some(idx),
211218
year: year - start.year + 1,
212219
extended_year: year,
213220
ambiguity: types::YearAmbiguity::CenturyRequired,
214221
}
215222
} else {
216-
types::EraYear {
217-
// TODO: return era indices?
218-
era_index: None,
219-
..CeBce.era_year_from_extended(year, month, day)
220-
}
223+
CeBce.era_year_from_extended(year, month, day)
221224
}
222225
}
223226

provider/data/datetime/data/datetime_names_year_japanese_v1.rs.data

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

provider/data/datetime/fingerprints.csv

Lines changed: 396 additions & 396 deletions
Large diffs are not rendered by default.

provider/source/data/debug/datetime/names/year/japanese/v1/3/ar-EG.json

Lines changed: 8 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

provider/source/data/debug/datetime/names/year/japanese/v1/3/ar.json

Lines changed: 8 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

provider/source/data/debug/datetime/names/year/japanese/v1/3/bn.json

Lines changed: 8 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

provider/source/data/debug/datetime/names/year/japanese/v1/3/ccp.json

Lines changed: 8 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

provider/source/data/debug/datetime/names/year/japanese/v1/3/en-001.json

Lines changed: 8 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

provider/source/data/debug/datetime/names/year/japanese/v1/3/en-ZA.json

Lines changed: 8 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)