Skip to content

Commit c0bd2c5

Browse files
committed
extended-year
1 parent e0c2dad commit c0bd2c5

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
@@ -1364,7 +1364,7 @@ mod tests {
13641364
} else {
13651365
assert_eq!(
13661366
year,
1367-
date.extended_year(),
1367+
date.year().extended_year(),
13681368
"Failed to roundtrip year for calendar {}",
13691369
calendar.debug_name()
13701370
);

components/calendar/src/cal/east_asian_traditional.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,7 +1208,7 @@ mod test {
12081208
let chinese = Date::from_rata_die(rata_die, ChineseTraditional::new());
12091209
assert_eq!(
12101210
case.expected_year,
1211-
chinese.extended_year(),
1211+
chinese.year().extended_year(),
12121212
"Chinese from RD failed, case: {case:?}"
12131213
);
12141214
assert_eq!(
@@ -1871,21 +1871,21 @@ mod test {
18711871
'outer: for long in [false, true] {
18721872
for (start_year, start_month, end_year, end_month, by) in [
18731873
(
1874-
reference_year_end.extended_year(),
1874+
reference_year_end.year().extended_year(),
18751875
reference_year_end.month().number(),
1876-
year_1900_start.extended_year(),
1876+
year_1900_start.year().extended_year(),
18771877
year_1900_start.month().number(),
18781878
-1,
18791879
),
18801880
(
1881-
reference_year_end.extended_year(),
1881+
reference_year_end.year().extended_year(),
18821882
reference_year_end.month().number(),
1883-
year_2035_end.extended_year(),
1883+
year_2035_end.year().extended_year(),
18841884
year_2035_end.month().number(),
18851885
1,
18861886
),
18871887
(
1888-
year_1900_start.extended_year(),
1888+
year_1900_start.year().extended_year(),
18891889
year_1900_start.month().number(),
18901890
-10000,
18911891
1,

components/calendar/src/cal/ethiopian.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ mod test {
321321
// 2023-09-11 ISO is 2025-13-06 Ethiopian
322322
let rd = Date::try_new_iso(2023, 9, 11).unwrap().to_rata_die();
323323
let date_ethiopian = Date::from_rata_die(rd, Ethiopian::new());
324-
assert_eq!(date_ethiopian.extended_year(), 2015);
324+
assert_eq!(date_ethiopian.year().extended_year(), 2015);
325325
assert_eq!(date_ethiopian.month().ordinal, 13);
326326
assert_eq!(date_ethiopian.day_of_month().0, 6);
327327
}
@@ -331,7 +331,7 @@ mod test {
331331
let rd = Date::try_new_iso(1970, 1, 2).unwrap().to_rata_die();
332332
let date_ethiopian = Date::from_rata_die(rd, Ethiopian::new());
333333

334-
assert_eq!(date_ethiopian.extended_year(), 1962);
334+
assert_eq!(date_ethiopian.year().extended_year(), 1962);
335335
assert_eq!(date_ethiopian.month().ordinal, 4);
336336
assert_eq!(date_ethiopian.day_of_month().0, 24);
337337

@@ -343,7 +343,7 @@ mod test {
343343
let rd = Date::try_new_iso(1970, 1, 2).unwrap().to_rata_die();
344344
let date_ethiopian = Date::from_rata_die(rd, Ethiopian(EthiopianEraStyle::AmeteAlem));
345345

346-
assert_eq!(date_ethiopian.extended_year(), 7462);
346+
assert_eq!(date_ethiopian.year().extended_year(), 7462);
347347
assert_eq!(date_ethiopian.month().ordinal, 4);
348348
assert_eq!(date_ethiopian.day_of_month().0, 24);
349349

@@ -364,13 +364,15 @@ mod test {
364364
Date::try_new_iso(-5500 + 9, 1, 1)
365365
.unwrap()
366366
.to_calendar(Ethiopian(EthiopianEraStyle::AmeteAlem))
367+
.year()
367368
.extended_year(),
368369
1
369370
);
370371
assert_eq!(
371372
Date::try_new_iso(9, 1, 1)
372373
.unwrap()
373374
.to_calendar(Ethiopian(EthiopianEraStyle::AmeteAlem))
375+
.year()
374376
.extended_year(),
375377
5501
376378
);
@@ -379,13 +381,15 @@ mod test {
379381
Date::try_new_iso(-5500 + 9, 1, 1)
380382
.unwrap()
381383
.to_calendar(Ethiopian(EthiopianEraStyle::AmeteMihret))
384+
.year()
382385
.extended_year(),
383386
-5499
384387
);
385388
assert_eq!(
386389
Date::try_new_iso(9, 1, 1)
387390
.unwrap()
388391
.to_calendar(Ethiopian(EthiopianEraStyle::AmeteMihret))
392+
.year()
389393
.extended_year(),
390394
1
391395
);

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)