diff --git a/src/material-luxon-adapter/adapter/luxon-date-adapter.spec.ts b/src/material-luxon-adapter/adapter/luxon-date-adapter.spec.ts index 12a4a95f81f3..5eed39517609 100644 --- a/src/material-luxon-adapter/adapter/luxon-date-adapter.spec.ts +++ b/src/material-luxon-adapter/adapter/luxon-date-adapter.spec.ts @@ -258,7 +258,8 @@ describe('LuxonDateAdapter', () => { }); it('should get first day of week', () => { - expect(adapter.getFirstDayOfWeek()).toBe(0); + adapter.setLocale('bg-BG'); + expect(adapter.getFirstDayOfWeek()).toBe(1); }); it('should create Luxon date', () => { diff --git a/src/material-luxon-adapter/adapter/luxon-date-adapter.ts b/src/material-luxon-adapter/adapter/luxon-date-adapter.ts index 5e7ade456685..58296201a97d 100644 --- a/src/material-luxon-adapter/adapter/luxon-date-adapter.ts +++ b/src/material-luxon-adapter/adapter/luxon-date-adapter.ts @@ -27,7 +27,7 @@ export interface MatLuxonDateAdapterOptions { * Sets the first day of week. * Changing this will change how Angular Material components like DatePicker shows start of week. */ - firstDayOfWeek: number; + firstDayOfWeek?: number; /** * Sets the output Calendar. @@ -49,7 +49,6 @@ export const MAT_LUXON_DATE_ADAPTER_OPTIONS = new InjectionToken(length: number, valueFunction: (index: number) => T): T[] { @Injectable() export class LuxonDateAdapter extends DateAdapter { private _useUTC: boolean; - private _firstDayOfWeek: number; + private _firstDayOfWeek: number | undefined; private _defaultOutputCalendar: LuxonCalendarSystem; constructor(...args: unknown[]); @@ -81,7 +80,7 @@ export class LuxonDateAdapter extends DateAdapter { }); this._useUTC = !!options?.useUtc; - this._firstDayOfWeek = options?.firstDayOfWeek || 0; + this._firstDayOfWeek = options?.firstDayOfWeek; this._defaultOutputCalendar = options?.defaultOutputCalendar || 'gregory'; this.setLocale(dateLocale || LuxonDateTime.local().locale); } @@ -134,7 +133,7 @@ export class LuxonDateAdapter extends DateAdapter { } getFirstDayOfWeek(): number { - return this._firstDayOfWeek; + return this._firstDayOfWeek ?? LuxonInfo.getStartOfWeek({locale: this.locale}); } getNumDaysInMonth(date: LuxonDateTime): number {