Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions src/material-luxon-adapter/adapter/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@

import {NgModule, Provider} from '@angular/core';
import {DateAdapter, MAT_DATE_FORMATS, MatDateFormats} from '@angular/material/core';
import {LuxonDateAdapter} from './luxon-date-adapter';
import {
LuxonDateAdapter,
MAT_LUXON_DATE_ADAPTER_OPTIONS,
MatLuxonDateAdapterOptions,
} from './luxon-date-adapter';
import {MAT_LUXON_DATE_FORMATS} from './luxon-date-formats';

export * from './luxon-date-adapter';
Expand All @@ -31,12 +35,19 @@ export class MatLuxonDateModule {}

export function provideLuxonDateAdapter(
formats: MatDateFormats = MAT_LUXON_DATE_FORMATS,
options?: MatLuxonDateAdapterOptions,
): Provider[] {
return [
const providers: Provider[] = [
{
provide: DateAdapter,
useClass: LuxonDateAdapter,
},
{provide: MAT_DATE_FORMATS, useValue: formats},
];

if (options) {
providers.push({provide: MAT_LUXON_DATE_ADAPTER_OPTIONS, useValue: options});
}

return providers;
}
2 changes: 1 addition & 1 deletion src/material-luxon-adapter/adapter/luxon-date-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export interface MatLuxonDateAdapterOptions {
* Sets the output Calendar.
* Changing this will change how Angular Material components like DatePicker output dates.
*/
defaultOutputCalendar: LuxonCalendarSystem;
defaultOutputCalendar?: LuxonCalendarSystem;
}

/** InjectionToken for LuxonDateAdapter to configure options. */
Expand Down
Loading