Skip to content

Commit 6e4220c

Browse files
committed
extended-year
1 parent 0ebe3fd commit 6e4220c

File tree

21 files changed

+48
-47
lines changed

21 files changed

+48
-47
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
@@ -1589,7 +1589,7 @@ mod tests {
15891589
} else {
15901590
assert_eq!(
15911591
year,
1592-
date.extended_year(),
1592+
date.year().extended_year(),
15931593
"Failed to roundtrip year for calendar {}",
15941594
calendar.debug_name()
15951595
);

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
// 11th September 2023 in gregorian is 6/13/2015 in ethiopian
315315
let iso_date = Date::try_new_iso(2023, 9, 11).unwrap();
316316
let date_ethiopian = Date::new_from_iso(iso_date, 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 iso_date = Date::try_new_iso(1970, 1, 2).unwrap();
325325
let date_ethiopian = Date::new_from_iso(iso_date, 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

@@ -339,7 +339,7 @@ mod test {
339339
let iso_date = Date::try_new_iso(1970, 1, 2).unwrap();
340340
let date_ethiopian = Date::new_from_iso(iso_date, Ethiopian(EthiopianEraStyle::AmeteAlem));
341341

342-
assert_eq!(date_ethiopian.extended_year(), 7462);
342+
assert_eq!(date_ethiopian.year().extended_year(), 7462);
343343
assert_eq!(date_ethiopian.month().ordinal, 4);
344344
assert_eq!(date_ethiopian.day_of_month().0, 24);
345345

@@ -365,6 +365,7 @@ mod test {
365365
Date::try_new_iso(-5500 + 9, 1, 1).unwrap(),
366366
Ethiopian(EthiopianEraStyle::AmeteAlem)
367367
)
368+
.year()
368369
.extended_year(),
369370
1
370371
);
@@ -373,6 +374,7 @@ mod test {
373374
Date::try_new_iso(9, 1, 1).unwrap(),
374375
Ethiopian(EthiopianEraStyle::AmeteAlem)
375376
)
377+
.year()
376378
.extended_year(),
377379
5501
378380
);
@@ -382,6 +384,7 @@ mod test {
382384
Date::try_new_iso(-5500 + 9, 1, 1).unwrap(),
383385
Ethiopian(EthiopianEraStyle::AmeteMihret)
384386
)
387+
.year()
385388
.extended_year(),
386389
-5499
387390
);
@@ -390,6 +393,7 @@ mod test {
390393
Date::try_new_iso(9, 1, 1).unwrap(),
391394
Ethiopian(EthiopianEraStyle::AmeteMihret)
392395
)
396+
.year()
393397
.extended_year(),
394398
1
395399
);

components/calendar/src/cal/roc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ mod test {
150150
"Failed era check from RD: {case:?}\nISO: {iso_from_rd:?}\nROC: {roc_from_rd:?}"
151151
);
152152
assert_eq!(
153-
roc_from_rd.extended_year(),
153+
roc_from_rd.year().extended_year(),
154154
if case.expected_era == "roc" {
155155
case.expected_year
156156
} else {

components/calendar/src/date.rs

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

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

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)