Skip to content

Commit 076477a

Browse files
committed
era indices
1 parent ea38358 commit 076477a

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
@@ -201,24 +201,27 @@ impl GregorianYears for &'_ Japanese {
201201
fn era_year_from_extended(&self, year: i32, month: u8, day: u8) -> types::EraYear {
202202
let date: EraStartDate = EraStartDate { year, month, day };
203203

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

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)