@@ -265,6 +265,12 @@ class Calendar extends CalendarPart {
265265 @property ( )
266266 _headerYearButtonTextSecType ?: string ;
267267
268+ @property ( )
269+ _headerYearRangeButtonText ?: string ;
270+
271+ @property ( )
272+ _headerYearRangeButtonTextSecType ?: string ;
273+
268274 @property ( { noAttribute : true } )
269275 _pickersMode : `${CalendarPickersMode } ` = "DAY_MONTH_YEAR" ;
270276
@@ -477,16 +483,16 @@ class Calendar extends CalendarPart {
477483 const yearFormat = DateFormat . getDateInstance ( { format : "y" , calendarType : this . primaryCalendarType } ) ;
478484 const localeData = getCachedLocaleDataInstance ( getLocale ( ) ) ;
479485 this . _headerMonthButtonText = localeData . getMonthsStandAlone ( "wide" , this . primaryCalendarType ) [ this . _calendarDate . getMonth ( ) ] ;
486+ this . _headerYearButtonText = String ( yearFormat . format ( this . _localDate , true ) ) ;
480487
481488 if ( this . _currentPicker === "year" ) {
482489 const rangeStart = new CalendarDateComponent ( this . _calendarDate , this . _primaryCalendarType ) ;
483490 const rangeEnd = new CalendarDateComponent ( this . _calendarDate , this . _primaryCalendarType ) ;
491+
484492 rangeStart . setYear ( this . _currentPickerDOM . _firstYear ! ) ;
485493 rangeEnd . setYear ( this . _currentPickerDOM . _lastYear ! ) ;
486494
487- this . _headerYearButtonText = `${ yearFormat . format ( rangeStart . toLocalJSDate ( ) , true ) } - ${ yearFormat . format ( rangeEnd . toLocalJSDate ( ) , true ) } ` ;
488- } else {
489- this . _headerYearButtonText = String ( yearFormat . format ( this . _localDate , true ) ) ;
495+ this . _headerYearRangeButtonText = `${ yearFormat . format ( rangeStart . toLocalJSDate ( ) ) } - ${ yearFormat . format ( rangeEnd . toLocalJSDate ( ) ) } ` ;
490496 }
491497
492498 this . _secondaryCalendarType && this . _setSecondaryCalendarTypeButtonText ( ) ;
@@ -553,20 +559,21 @@ class Calendar extends CalendarPart {
553559
554560 _setSecondaryCalendarTypeButtonText ( ) {
555561 const yearFormatSecType = DateFormat . getDateInstance ( { format : "y" , calendarType : this . _secondaryCalendarType } ) ;
562+ this . _headerYearButtonTextSecType = String ( yearFormatSecType . format ( this . _localDate , true ) ) ;
556563
557564 if ( this . _currentPicker === "year" ) {
558565 const rangeStart = new CalendarDateComponent ( this . _calendarDate , this . _primaryCalendarType ) ;
559566 const rangeEnd = new CalendarDateComponent ( this . _calendarDate , this . _primaryCalendarType ) ;
567+
560568 rangeStart . setYear ( this . _currentPickerDOM . _firstYear ! ) ;
561569 rangeEnd . setYear ( this . _currentPickerDOM . _lastYear ! ) ;
562570
563571 const rangeStartSecType = transformDateToSecondaryType ( this . primaryCalendarType , this . _secondaryCalendarType , rangeStart . valueOf ( ) / 1000 , true )
564572 . firstDate ;
565573 const rangeEndSecType = transformDateToSecondaryType ( this . primaryCalendarType , this . _secondaryCalendarType , rangeEnd . valueOf ( ) / 1000 , true )
566574 . lastDate ;
567- this . _headerYearButtonTextSecType = `${ yearFormatSecType . format ( rangeStartSecType . toLocalJSDate ( ) , true ) } - ${ yearFormatSecType . format ( rangeEndSecType . toLocalJSDate ( ) , true ) } ` ;
568- } else {
569- this . _headerYearButtonTextSecType = String ( yearFormatSecType . format ( this . _localDate , true ) ) ;
575+
576+ this . _headerYearRangeButtonTextSecType = `${ yearFormatSecType . format ( rangeStartSecType . toLocalJSDate ( ) ) } - ${ yearFormatSecType . format ( rangeEndSecType . toLocalJSDate ( ) ) } ` ;
570577 }
571578 }
572579
@@ -616,6 +623,10 @@ class Calendar extends CalendarPart {
616623 return this . _currentPicker !== "year" ;
617624 }
618625
626+ get _isHeaderYearRangeButtonHidden ( ) {
627+ return this . _currentPicker !== "year" ;
628+ }
629+
619630 _fireEventAndUpdateSelectedDates ( selectedDates : Array < number > ) {
620631 const datesValues = selectedDates . map ( timestamp => {
621632 const calendarDate = CalendarDateComponent . fromTimestamp ( timestamp * 1000 , this . _primaryCalendarType ) ;
0 commit comments