Skip to content

Commit

Permalink
feat(DatePicker): replaced default locale for easy language switching
Browse files Browse the repository at this point in the history
  • Loading branch information
N00nDay committed Jul 19, 2023
1 parent 3c410a6 commit 5e91023
Showing 1 changed file with 25 additions and 14 deletions.
39 changes: 25 additions & 14 deletions src/lib/components/datepicker/locale.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import dayjs from 'dayjs';

export type Locale = {
weekdays?: string[];
months?: string[];
Expand All @@ -8,24 +10,33 @@ type InnerLocale = {
months: string[];
weekStartsOn: number;
};

export function getLocaleDefaults(): InnerLocale {
return {
weekdays: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'],
weekdays: [
dayjs().day(0).format('dd'),
dayjs().day(1).format('dd'),
dayjs().day(2).format('dd'),
dayjs().day(3).format('dd'),
dayjs().day(4).format('dd'),
dayjs().day(5).format('dd'),
dayjs().day(6).format('dd')
],
months: [
'January',
'February',
'March',
'April',
'May',
'June',
'July',
'August',
'September',
'October',
'November',
'December'
dayjs().month(0).format('MMMM'),
dayjs().month(1).format('MMMM'),
dayjs().month(2).format('MMMM'),
dayjs().month(3).format('MMMM'),
dayjs().month(4).format('MMMM'),
dayjs().month(5).format('MMMM'),
dayjs().month(6).format('MMMM'),
dayjs().month(7).format('MMMM'),
dayjs().month(8).format('MMMM'),
dayjs().month(9).format('MMMM'),
dayjs().month(10).format('MMMM'),
dayjs().month(11).format('MMMM')
],
weekStartsOn: 1
weekStartsOn: 0
};
}
export function getInnerLocale(locale: Locale = {}): InnerLocale {
Expand Down

0 comments on commit 5e91023

Please sign in to comment.