Skip to content

Commit b0654c4

Browse files
refactor(moment-date-adapter): destructure options
useUtc has been made optional to prevent the necessity for default values.
1 parent 4245779 commit b0654c4

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/material-moment-adapter/adapter/moment-date-adapter.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export interface MatMomentDateAdapterOptions {
3333
* Changing this will change how Angular Material components like DatePicker output dates.
3434
* {@default false}
3535
*/
36-
useUtc: boolean;
36+
useUtc?: boolean;
3737
}
3838

3939
/** InjectionToken for moment date adapter to configure options. */
@@ -253,8 +253,9 @@ export class MomentDateAdapter extends DateAdapter<Moment> {
253253
format?: MomentFormatSpecification,
254254
locale?: string,
255255
): Moment {
256-
const strict = this._options ? this._options.strict : undefined;
257-
return (this._options && this._options.useUtc)
256+
const {strict, useUtc}: MatMomentDateAdapterOptions = this._options || {};
257+
258+
return useUtc
258259
? moment.utc(date, format, locale, strict)
259260
: moment(date, format, locale, strict);
260261
}

0 commit comments

Comments
 (0)