angular / angular/components

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

Open
#32,935 0 comments 0 reactions 0 assignees View on GitHub
area: material/datepicker docs P3
Dominant language
TypeScript
Stars
25k
Forks
6.8k
Avg merge
1d 8h
Merged PRs (30d)
91

Description

### 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:
>
> ```ts
> bootstrapApplication(MyApp, {
> providers: [provideLuxonDateAdapter(undefined, {useUtc: true})]
> });
> ```

[`provideLuxonDateAdapter()` only takes the 1 parameter](https://github.com/angular/components/blob/46b67d15053ce31b4742b809f1777b32eb2f1863/src/material-luxon-adapter/adapter/index.ts#L32-L34), 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](https://github.com/angular/components/pull/32936) copying the Moment adapter.

The current actual way to achieve it is:
```ts
bootstrapApplication(MyApp, {
providers: [
provideLuxonDateAdapter(),
{
provide: MAT_LUXON_DATE_ADAPTER_OPTIONS,
useValue: {
useUtc: true,
} satisfies Partial,
},
]
});
```

### Affected documentation page

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

Contributor guide

Open the contributing guide

Research direction

Open the affected datepicker overview page and compare its LuxonDateAdapter example with the linked adapter source at src/material-luxon-adapter/adapter/index.ts. Review the existing PR and update the documentation so the described configuration matches the supported API and the documented UTC setup is accurate.

Written by the indexing model from the issue text.

Assessment

Tech stack
angular, typescript
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.