Skip to content

docs-bug(datepicker): Wrong docs for parsing dates as UTC with luxon #32935

@StavNoyAkur8

Description

@StavNoyAkur8

Documentation Feedback

The docs include this extract:

By default the LuxonDateAdapter creates dates in your time zone specific locale. You can change the default behaviour to parse dates as UTC by passing useUtc: true into provideLuxonDateAdapter:

bootstrapApplication(MyApp, {
  providers: [provideLuxonDateAdapter(undefined, {useUtc: true})]
});

provideLuxonDateAdapter() only takes the 1 parameter, no second options with useUtc.

My guess is this is a holdover from Moment, which does have this option.
It would be nice, and fairly easy, to actually have this same option.
edit: I went ahead and made a PR copying the Moment adapter.

The current actual way to achieve it is:

bootstrapApplication(MyApp, {
  providers: [
    provideLuxonDateAdapter(),
    {
      provide: MAT_LUXON_DATE_ADAPTER_OPTIONS,
      useValue: {
        useUtc: true,
      } satisfies Partial<MatLuxonDateAdapterOptions>,
    },
  ]
});

Affected documentation page

https://material.angular.dev/components/datepicker/overview#choosing-a-date-implementation-and-date-format-settings

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: material/datepickerdocsThis issue is related to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions