Skip to content

Commit eeb9b88

Browse files
committed
extended-year
1 parent 3c465c9 commit eeb9b88

File tree

21 files changed

+49
-48
lines changed

21 files changed

+49
-48
lines changed

components/calendar/fuzz/fuzz_targets/construction.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ fuzz_target!(|data: FuzzInput| {
2525
let _ = date.day_of_year();
2626
let _ = date.days_in_month();
2727
let _ = date.days_in_year();
28-
let _ = date.extended_year();
2928
let _ = date.is_in_leap_year();
3029
let _ = date.month();
3130
let _ = date.months_in_year();

components/calendar/src/any_calendar.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1594,7 +1594,7 @@ mod tests {
15941594
} else {
15951595
assert_eq!(
15961596
year,
1597-
date.extended_year(),
1597+
date.year().extended_year(),
15981598
"Failed to roundtrip year for calendar {}",
15991599
calendar.debug_name()
16001600
);

components/calendar/src/cal/east_asian_traditional.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1206,7 +1206,7 @@ mod test {
12061206
let chinese = Date::from_rata_die(rata_die, ChineseTraditional::new());
12071207
assert_eq!(
12081208
case.expected_year,
1209-
chinese.extended_year(),
1209+
chinese.year().extended_year(),
12101210
"Chinese from RD failed, case: {case:?}"
12111211
);
12121212
assert_eq!(
@@ -1869,21 +1869,21 @@ mod test {
18691869
'outer: for long in [false, true] {
18701870
for (start_year, start_month, end_year, end_month, by) in [
18711871
(
1872-
reference_year_end.extended_year(),
1872+
reference_year_end.year().extended_year(),
18731873
reference_year_end.month().number(),
1874-
year_1900_start.extended_year(),
1874+
year_1900_start.year().extended_year(),
18751875
year_1900_start.month().number(),
18761876
-1,
18771877
),
18781878
(
1879-
reference_year_end.extended_year(),
1879+
reference_year_end.year().extended_year(),
18801880
reference_year_end.month().number(),
1881-
year_2035_end.extended_year(),
1881+
year_2035_end.year().extended_year(),
18821882
year_2035_end.month().number(),
18831883
1,
18841884
),
18851885
(
1886-
year_1900_start.extended_year(),
1886+
year_1900_start.year().extended_year(),
18871887
year_1900_start.month().number(),
18881888
-10000,
18891889
1,

components/calendar/src/cal/ethiopian.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ mod test {
314314
// 2023-09-11 ISO is 2025-13-06 Ethiopian
315315
let rd = Date::try_new_iso(2023, 9, 11).unwrap().to_rata_die();
316316
let date_ethiopian = Date::from_rata_die(rd, Ethiopian::new());
317-
assert_eq!(date_ethiopian.extended_year(), 2015);
317+
assert_eq!(date_ethiopian.year().extended_year(), 2015);
318318
assert_eq!(date_ethiopian.month().ordinal, 13);
319319
assert_eq!(date_ethiopian.day_of_month().0, 6);
320320
}
@@ -324,7 +324,7 @@ mod test {
324324
let rd = Date::try_new_iso(1970, 1, 2).unwrap().to_rata_die();
325325
let date_ethiopian = Date::from_rata_die(rd, Ethiopian::new());
326326

327-
assert_eq!(date_ethiopian.extended_year(), 1962);
327+
assert_eq!(date_ethiopian.year().extended_year(), 1962);
328328
assert_eq!(date_ethiopian.month().ordinal, 4);
329329
assert_eq!(date_ethiopian.day_of_month().0, 24);
330330

@@ -336,7 +336,7 @@ mod test {
336336
let rd = Date::try_new_iso(1970, 1, 2).unwrap().to_rata_die();
337337
let date_ethiopian = Date::from_rata_die(rd, Ethiopian(EthiopianEraStyle::AmeteAlem));
338338

339-
assert_eq!(date_ethiopian.extended_year(), 7462);
339+
assert_eq!(date_ethiopian.year().extended_year(), 7462);
340340
assert_eq!(date_ethiopian.month().ordinal, 4);
341341
assert_eq!(date_ethiopian.day_of_month().0, 24);
342342

@@ -357,13 +357,15 @@ mod test {
357357
Date::try_new_iso(-5500 + 9, 1, 1)
358358
.unwrap()
359359
.to_calendar(Ethiopian(EthiopianEraStyle::AmeteAlem))
360+
.year()
360361
.extended_year(),
361362
1
362363
);
363364
assert_eq!(
364365
Date::try_new_iso(9, 1, 1)
365366
.unwrap()
366367
.to_calendar(Ethiopian(EthiopianEraStyle::AmeteAlem))
368+
.year()
367369
.extended_year(),
368370
5501
369371
);
@@ -372,13 +374,15 @@ mod test {
372374
Date::try_new_iso(-5500 + 9, 1, 1)
373375
.unwrap()
374376
.to_calendar(Ethiopian(EthiopianEraStyle::AmeteMihret))
377+
.year()
375378
.extended_year(),
376379
-5499
377380
);
378381
assert_eq!(
379382
Date::try_new_iso(9, 1, 1)
380383
.unwrap()
381384
.to_calendar(Ethiopian(EthiopianEraStyle::AmeteMihret))
385+
.year()
382386
.extended_year(),
383387
1
384388
);

components/calendar/src/cal/roc.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ mod test {
146146
"Failed era check from RD: {case:?}\nROC: {roc_from_rd:?}"
147147
);
148148
assert_eq!(
149-
roc_from_rd.extended_year(),
149+
roc_from_rd.year().extended_year(),
150150
if case.era == "roc" {
151151
case.year
152152
} else {
@@ -166,7 +166,7 @@ mod test {
166166
);
167167

168168
let roc_from_case = Date::try_new_roc(
169-
roc_from_rd.extended_year(),
169+
roc_from_rd.year().extended_year(),
170170
roc_from_rd.month().ordinal,
171171
roc_from_rd.day_of_month().0,
172172
)

components/calendar/src/date.rs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -286,19 +286,9 @@ impl<A: AsCalendar> Date<A> {
286286
self.calendar.as_calendar().year_info(&self.inner).into()
287287
}
288288

289-
/// The "extended year" of this date.
290-
///
291-
/// This year number can be used when you need a simple numeric representation
292-
/// of the year, and can be meaningfully compared with extended years from other
293-
/// eras or used in arithmetic.
294-
///
295-
/// For calendars defined in Temporal, this will match the "arithmetic year"
296-
/// as defined in <https://tc39.es/proposal-intl-era-monthcode/>.
297-
/// This is typically anchored with year 1 as the year 1 of either the most modern or
298-
/// otherwise some "major" era for the calendar.
299-
///
300-
/// See [`Self::year()`] for more information about the year.
289+
/// Use [`YearInfo::extended_year`](types::YearInfo::extended_year)
301290
#[inline]
291+
#[deprecated(since = "2.2.0", note = "use `date.year().extended_year()`")]
302292
pub fn extended_year(&self) -> i32 {
303293
self.year().extended_year()
304294
}

components/calendar/src/types.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ mod unstable {
7070
///
7171
/// For an example, see [`Self::extended_year`].
7272
pub era_year: Option<i32>,
73-
/// See [`Date::extended_year()`](crate::Date::extended_year).
73+
/// See [`YearInfo::extended_year()`](crate::types::YearInfo::extended_year).
7474
///
7575
/// If both this and [`Self::era`]/[`Self::era_year`] are set, they must
7676
/// refer to the same year.
@@ -259,8 +259,16 @@ impl YearInfo {
259259
}
260260
}
261261

262-
/// Get the extended year (See [`Date::extended_year`](crate::Date::extended_year))
263-
/// for more information
262+
/// The "extended year".
263+
///
264+
/// This year number can be used when you need a simple numeric representation
265+
/// of the year, and can be meaningfully compared with extended years from other
266+
/// eras or used in arithmetic.
267+
///
268+
/// For calendars defined in Temporal, this will match the "arithmetic year"
269+
/// as defined in <https://tc39.es/proposal-intl-era-monthcode/>.
270+
/// This is typically anchored with year 1 as the year 1 of either the most modern or
271+
/// otherwise some "major" era for the calendar.
264272
pub fn extended_year(self) -> i32 {
265273
match self {
266274
YearInfo::Era(e) => e.extended_year,

components/calendar/tests/extended_year.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ fn test_extended_year() {
4444
Date::try_new_from_codes(None, 0, m_01.code(), 1, calendar.clone()).unwrap();
4545
let iso_date_in_epoch_year = date_in_epoch_year.to_calendar(iso);
4646
assert_eq!(
47-
iso_date_in_epoch_year.extended_year(),
47+
iso_date_in_epoch_year.year().extended_year(),
4848
*extended_epoch,
4949
"Extended year for {date_in_epoch_year:?} should be {extended_epoch}"
5050
);
@@ -67,7 +67,7 @@ fn test_extended_year() {
6767
AnyCalendarKind::Japanese | AnyCalendarKind::JapaneseExtended
6868
) {
6969
assert_eq!(
70-
date_in_2025.extended_year(),
70+
date_in_2025.year().extended_year(),
7171
2025,
7272
"Extended year for {date_in_2025:?} should be 2025"
7373
);
@@ -76,7 +76,7 @@ fn test_extended_year() {
7676
// These two function calls are not equivalent in general.
7777
let expected = date_in_2025.year().era_year_or_related_iso();
7878
assert_eq!(
79-
date_in_2025.extended_year(),
79+
date_in_2025.year().extended_year(),
8080
expected,
8181
"Extended year for {date_in_2025:?} should be {expected}"
8282
);

components/icu/examples/iso_date_manipulations.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ fn main() {
3232
let date = Date::try_new_iso(year, month, day).expect("date should parse");
3333
println!(
3434
"Year: {}, Month: {}, Day: {}",
35-
date.extended_year(),
35+
date.year().extended_year(),
3636
date.month().ordinal,
3737
date.day_of_month().0,
3838
);

components/time/src/ixdtf.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ impl<A: AsCalendar> ZonedDateTime<A, TimeZoneInfo<models::AtTime>> {
469469
/// )
470470
/// .unwrap();
471471
///
472-
/// assert_eq!(zoneddatetime.date.extended_year(), 5784);
472+
/// assert_eq!(zoneddatetime.date.year().extended_year(), 5784);
473473
/// assert_eq!(
474474
/// zoneddatetime.date.month().standard_code,
475475
/// icu::calendar::types::MonthCode(tinystr::tinystr!(4, "M11"))

0 commit comments

Comments
 (0)