@@ -363,83 +363,83 @@ impl Calendar {
363
363
}
364
364
365
365
/// `CalendarEra`
366
- pub fn era ( & self , iso_date : & IsoDate ) -> TemporalResult < Option < TinyAsciiStr < 16 > > > {
366
+ pub fn era ( & self , iso_date : & IsoDate ) -> Option < TinyAsciiStr < 16 > > {
367
367
if self . is_iso ( ) {
368
- return Ok ( None ) ;
368
+ return None ;
369
369
}
370
- let calendar_date = self . 0 . date_from_iso ( iso_date. as_icu4x ( ) ? ) ;
371
- Ok ( self . 0 . year ( & calendar_date) . standard_era ( ) . map ( |era| era. 0 ) )
370
+ let calendar_date = self . 0 . date_from_iso ( iso_date. to_icu4x ( ) ) ;
371
+ self . 0 . year ( & calendar_date) . standard_era ( ) . map ( |era| era. 0 )
372
372
}
373
373
374
374
/// `CalendarEraYear`
375
- pub fn era_year ( & self , iso_date : & IsoDate ) -> TemporalResult < Option < i32 > > {
375
+ pub fn era_year ( & self , iso_date : & IsoDate ) -> Option < i32 > {
376
376
if self . is_iso ( ) {
377
- return Ok ( None ) ;
377
+ return None ;
378
378
}
379
- let calendar_date = self . 0 . date_from_iso ( iso_date. as_icu4x ( ) ? ) ;
380
- Ok ( self . 0 . year ( & calendar_date) . era_year ( ) )
379
+ let calendar_date = self . 0 . date_from_iso ( iso_date. to_icu4x ( ) ) ;
380
+ self . 0 . year ( & calendar_date) . era_year ( )
381
381
}
382
382
383
383
/// `CalendarYear`
384
- pub fn year ( & self , iso_date : & IsoDate ) -> TemporalResult < i32 > {
384
+ pub fn year ( & self , iso_date : & IsoDate ) -> i32 {
385
385
if self . is_iso ( ) {
386
- return Ok ( iso_date. year ) ;
386
+ return iso_date. year ;
387
387
}
388
- let calendar_date = self . 0 . date_from_iso ( iso_date. as_icu4x ( ) ? ) ;
389
- Ok ( self . 0 . year ( & calendar_date) . extended_year )
388
+ let calendar_date = self . 0 . date_from_iso ( iso_date. to_icu4x ( ) ) ;
389
+ self . 0 . year ( & calendar_date) . extended_year
390
390
}
391
391
392
392
/// `CalendarMonth`
393
- pub fn month ( & self , iso_date : & IsoDate ) -> TemporalResult < u8 > {
393
+ pub fn month ( & self , iso_date : & IsoDate ) -> u8 {
394
394
if self . is_iso ( ) {
395
- return Ok ( iso_date. month ) ;
395
+ return iso_date. month ;
396
396
}
397
- let calendar_date = self . 0 . date_from_iso ( iso_date. as_icu4x ( ) ? ) ;
398
- Ok ( self . 0 . month ( & calendar_date) . month_number ( ) )
397
+ let calendar_date = self . 0 . date_from_iso ( iso_date. to_icu4x ( ) ) ;
398
+ self . 0 . month ( & calendar_date) . month_number ( )
399
399
}
400
400
401
401
/// `CalendarMonthCode`
402
- pub fn month_code ( & self , iso_date : & IsoDate ) -> TemporalResult < MonthCode > {
402
+ pub fn month_code ( & self , iso_date : & IsoDate ) -> MonthCode {
403
403
if self . is_iso ( ) {
404
- let mc = iso_date. as_icu4x ( ) ? . month ( ) . standard_code . 0 ;
405
- return Ok ( MonthCode ( mc) ) ;
404
+ let mc = iso_date. to_icu4x ( ) . month ( ) . standard_code . 0 ;
405
+ return MonthCode ( mc) ;
406
406
}
407
- let calendar_date = self . 0 . date_from_iso ( iso_date. as_icu4x ( ) ? ) ;
408
- Ok ( MonthCode ( self . 0 . month ( & calendar_date) . standard_code . 0 ) )
407
+ let calendar_date = self . 0 . date_from_iso ( iso_date. to_icu4x ( ) ) ;
408
+ MonthCode ( self . 0 . month ( & calendar_date) . standard_code . 0 )
409
409
}
410
410
411
411
/// `CalendarDay`
412
- pub fn day ( & self , iso_date : & IsoDate ) -> TemporalResult < u8 > {
412
+ pub fn day ( & self , iso_date : & IsoDate ) -> u8 {
413
413
if self . is_iso ( ) {
414
- return Ok ( iso_date. day ) ;
414
+ return iso_date. day ;
415
415
}
416
- let calendar_date = self . 0 . date_from_iso ( iso_date. as_icu4x ( ) ? ) ;
417
- Ok ( self . 0 . day_of_month ( & calendar_date) . 0 )
416
+ let calendar_date = self . 0 . date_from_iso ( iso_date. to_icu4x ( ) ) ;
417
+ self . 0 . day_of_month ( & calendar_date) . 0
418
418
}
419
419
420
420
/// `CalendarDayOfWeek`
421
- pub fn day_of_week ( & self , iso_date : & IsoDate ) -> TemporalResult < u16 > {
421
+ pub fn day_of_week ( & self , iso_date : & IsoDate ) -> u16 {
422
422
if self . is_iso ( ) {
423
- return Ok ( iso_date. as_icu4x ( ) ? . day_of_week ( ) as u16 ) ;
423
+ return iso_date. to_icu4x ( ) . day_of_week ( ) as u16 ;
424
424
}
425
- let calendar_date = self . 0 . date_from_iso ( iso_date. as_icu4x ( ) ? ) ;
425
+ let calendar_date = self . 0 . date_from_iso ( iso_date. to_icu4x ( ) ) ;
426
426
// TODO: Understand ICU4X's decision for `IsoWeekDay` to be `i8`
427
- Ok ( self . 0 . day_of_week ( & calendar_date) as u16 )
427
+ self . 0 . day_of_week ( & calendar_date) as u16
428
428
}
429
429
430
430
/// `CalendarDayOfYear`
431
- pub fn day_of_year ( & self , iso_date : & IsoDate ) -> TemporalResult < u16 > {
431
+ pub fn day_of_year ( & self , iso_date : & IsoDate ) -> u16 {
432
432
if self . is_iso ( ) {
433
- return Ok ( iso_date. as_icu4x ( ) ? . day_of_year_info ( ) . day_of_year ) ;
433
+ return iso_date. to_icu4x ( ) . day_of_year_info ( ) . day_of_year ;
434
434
}
435
- let calendar_date = self . 0 . date_from_iso ( iso_date. as_icu4x ( ) ? ) ;
436
- Ok ( self . 0 . day_of_year_info ( & calendar_date) . day_of_year )
435
+ let calendar_date = self . 0 . date_from_iso ( iso_date. to_icu4x ( ) ) ;
436
+ self . 0 . day_of_year_info ( & calendar_date) . day_of_year
437
437
}
438
438
439
439
/// `CalendarWeekOfYear`
440
440
pub fn week_of_year ( & self , iso_date : & IsoDate ) -> TemporalResult < Option < u16 > > {
441
441
if self . is_iso ( ) {
442
- let date = iso_date. as_icu4x ( ) ? ;
442
+ let date = iso_date. to_icu4x ( ) ;
443
443
let week_calculator = WeekCalculator :: default ( ) ;
444
444
let week_of = date. week_of_year ( & week_calculator) ;
445
445
return Ok ( Some ( week_of. week as u16 ) ) ;
@@ -451,7 +451,7 @@ impl Calendar {
451
451
/// `CalendarYearOfWeek`
452
452
pub fn year_of_week ( & self , iso_date : & IsoDate ) -> TemporalResult < Option < i32 > > {
453
453
if self . is_iso ( ) {
454
- let date = iso_date. as_icu4x ( ) ? ;
454
+ let date = iso_date. to_icu4x ( ) ;
455
455
456
456
let week_calculator = WeekCalculator :: default ( ) ;
457
457
@@ -477,39 +477,39 @@ impl Calendar {
477
477
}
478
478
479
479
/// `CalendarDaysInMonth`
480
- pub fn days_in_month ( & self , iso_date : & IsoDate ) -> TemporalResult < u16 > {
480
+ pub fn days_in_month ( & self , iso_date : & IsoDate ) -> u16 {
481
481
if self . is_iso ( ) {
482
- return Ok ( iso_date. as_icu4x ( ) ? . days_in_month ( ) as u16 ) ;
482
+ return iso_date. to_icu4x ( ) . days_in_month ( ) as u16 ;
483
483
}
484
- let calendar_date = self . 0 . date_from_iso ( iso_date. as_icu4x ( ) ? ) ;
485
- Ok ( self . 0 . days_in_month ( & calendar_date) as u16 )
484
+ let calendar_date = self . 0 . date_from_iso ( iso_date. to_icu4x ( ) ) ;
485
+ self . 0 . days_in_month ( & calendar_date) as u16
486
486
}
487
487
488
488
/// `CalendarDaysInYear`
489
- pub fn days_in_year ( & self , iso_date : & IsoDate ) -> TemporalResult < u16 > {
489
+ pub fn days_in_year ( & self , iso_date : & IsoDate ) -> u16 {
490
490
if self . is_iso ( ) {
491
- return Ok ( iso_date. as_icu4x ( ) ? . days_in_year ( ) ) ;
491
+ return iso_date. to_icu4x ( ) . days_in_year ( ) ;
492
492
}
493
- let calendar_date = self . 0 . date_from_iso ( iso_date. as_icu4x ( ) ? ) ;
494
- Ok ( self . 0 . days_in_year ( & calendar_date) )
493
+ let calendar_date = self . 0 . date_from_iso ( iso_date. to_icu4x ( ) ) ;
494
+ self . 0 . days_in_year ( & calendar_date)
495
495
}
496
496
497
497
/// `CalendarMonthsInYear`
498
- pub fn months_in_year ( & self , iso_date : & IsoDate ) -> TemporalResult < u16 > {
498
+ pub fn months_in_year ( & self , iso_date : & IsoDate ) -> u16 {
499
499
if self . is_iso ( ) {
500
- return Ok ( 12 ) ;
500
+ return 12 ;
501
501
}
502
- let calendar_date = self . 0 . date_from_iso ( iso_date. as_icu4x ( ) ? ) ;
503
- Ok ( self . 0 . months_in_year ( & calendar_date) as u16 )
502
+ let calendar_date = self . 0 . date_from_iso ( iso_date. to_icu4x ( ) ) ;
503
+ self . 0 . months_in_year ( & calendar_date) as u16
504
504
}
505
505
506
506
/// `CalendarInLeapYear`
507
- pub fn in_leap_year ( & self , iso_date : & IsoDate ) -> TemporalResult < bool > {
507
+ pub fn in_leap_year ( & self , iso_date : & IsoDate ) -> bool {
508
508
if self . is_iso ( ) {
509
- return Ok ( iso_date. as_icu4x ( ) ? . is_in_leap_year ( ) ) ;
509
+ return iso_date. to_icu4x ( ) . is_in_leap_year ( ) ;
510
510
}
511
- let calendar_date = self . 0 . date_from_iso ( iso_date. as_icu4x ( ) ? ) ;
512
- Ok ( self . 0 . is_in_leap_year ( & calendar_date) )
511
+ let calendar_date = self . 0 . date_from_iso ( iso_date. to_icu4x ( ) ) ;
512
+ self . 0 . is_in_leap_year ( & calendar_date)
513
513
}
514
514
515
515
/// Returns the identifier of this calendar slot.
0 commit comments