@@ -10,6 +10,7 @@ import dayjs, { Dayjs } from 'dayjs';
1010import customParser from 'dayjs/plugin/customParseFormat' ;
1111import isSameOrAfter from 'dayjs/plugin/isSameOrAfter' ;
1212import isSameOrBefore from 'dayjs/plugin/isSameOrBefore' ;
13+ import localeData from 'dayjs/plugin/localeData' ;
1314import {
1415 DateChanged ,
1516 MonthNameValue ,
@@ -20,7 +21,7 @@ import {
2021dayjs . extend ( isSameOrAfter ) ;
2122dayjs . extend ( isSameOrBefore ) ;
2223dayjs . extend ( customParser ) ;
23-
24+ dayjs . extend ( localeData ) ;
2425@Component ( {
2526 selector : 'calendar' ,
2627 templateUrl : './calendar-component.html' ,
@@ -138,20 +139,7 @@ export class Calendar implements OnChanges {
138139 } ) ;
139140 }
140141 createTouchCalendarGridData ( ) : void {
141- const monthsList = [
142- 'January' ,
143- 'February' ,
144- 'March' ,
145- 'April' ,
146- 'May' ,
147- 'June' ,
148- 'July' ,
149- 'August' ,
150- 'September' ,
151- 'October' ,
152- 'November' ,
153- 'December' ,
154- ] ;
142+ const monthsList = dayjs . months ( ) ;
155143 this . yearsList = [ ] ;
156144 this . monthsList = [ ] ;
157145 for ( let i = 1900 ; i <= + dayjs ( ) . add ( 100 , 'year' ) . get ( 'year' ) ; i ++ ) {
@@ -220,9 +208,9 @@ export class Calendar implements OnChanges {
220208 }
221209 // if this months last week has less than 7 days then take next month's first week and merge them
222210 if ( thisMonthWeekList . slice ( - 1 ) [ 0 ] . length < 7 ) {
223- thisMonthWeekList [
224- thisMonthWeekList . length - 1
225- ] = thisMonthWeekList . slice ( - 1 ) [ 0 ] . concat ( this . getNextMonthFirstWeek ( ) ) ;
211+ thisMonthWeekList [ thisMonthWeekList . length - 1 ] = thisMonthWeekList
212+ . slice ( - 1 ) [ 0 ]
213+ . concat ( this . getNextMonthFirstWeek ( ) ) ;
226214 }
227215 // if total number of weeks is less than 6 then we need to add one more week
228216 // Here we add previous months second last week
@@ -238,7 +226,9 @@ export class Calendar implements OnChanges {
238226 this . weekEndOn = [ this . weekStartsOn , this . weekStartsOn + 6 ] ;
239227 }
240228 setWeekDays ( ) {
241- let weekDays = [ 'Su' , 'Mo' , 'Tu' , 'We' , 'Th' , 'Fr' , 'Sa' ] ;
229+ let weekDays : string [ ] = dayjs
230+ . weekdaysShort ( )
231+ . map ( ( x ) => x . replace ( / [ a - z A - Z ] { 1 } $ / , '' ) ) ;
242232 weekDays = [
243233 ...weekDays . slice ( this . weekStartsOn , 7 ) ,
244234 ...weekDays . slice ( 0 , this . weekStartsOn ) ,
0 commit comments