Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 524dea7

Browse files
fix: using locales from dayjs
1 parent 9ec913d commit 524dea7

File tree

1 file changed

+9
-19
lines changed

1 file changed

+9
-19
lines changed

‎projects/angular-datetimerangepicker/src/calendar/calendar-component.ts‎

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import dayjs, { Dayjs } from 'dayjs';
1010
import customParser from 'dayjs/plugin/customParseFormat';
1111
import isSameOrAfter from 'dayjs/plugin/isSameOrAfter';
1212
import isSameOrBefore from 'dayjs/plugin/isSameOrBefore';
13+
import localeData from 'dayjs/plugin/localeData';
1314
import {
1415
DateChanged,
1516
MonthNameValue,
@@ -20,7 +21,7 @@ import {
2021
dayjs.extend(isSameOrAfter);
2122
dayjs.extend(isSameOrBefore);
2223
dayjs.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-zA-Z]{1}$/, ''));
242232
weekDays = [
243233
...weekDays.slice(this.weekStartsOn, 7),
244234
...weekDays.slice(0, this.weekStartsOn),

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /