ng-matero/extensions

Time-Parsing with `provideLuxonDatetimeAdapter`

Closed this issue · 4 comments

In your demo (https://ng-matero.github.io/extensions/components/datetimepicker/overview) I can put quite simple formats and the component / the adapter tries it's best to find the correct value (e.g. time-input 7 gets pared to 07:00. But using your LuxonDatetimeAdapter it seams like I need to put in the absolute correct format.

Is this an issue of this adapter? Or am I configuring something wrong?

Can you provide an online example?

Just cloned your repo and just needed to change that single line:

Replace it with provideLuxonDatetimeAdapter and you'll notice that from now on you need to pass the exact format on input while with the provideMomentDatetimeAdapter the input gets parsed / auto-corrected.

The date formats of moment and luxon are different. You can't just replace the provide* API. Please check the issue #141

export const MTX_LUXON_DATETIME_FORMATS: MtxDatetimeFormats = {
parse: {
dateInput: 'D',
monthInput: 'LLLL',
yearInput: 'yyyy',
datetimeInput: 'f',
timeInput: 't',
},
display: {
dateInput: 'D',
monthInput: 'LLLL',
yearInput: 'yyyy',
datetimeInput: 'f',
timeInput: 't',
monthYearLabel: 'yyyy',
dateA11yLabel: 'DDD',
monthYearA11yLabel: 'LLLL yyyy',
popupHeaderDateLabel: 'ccc, dd LLL',
},
};

@nzbin yeah, sorry. Should have noted that format doesn't make a difference. If you just put provideMomentDatetimeAdapter() (falling back to default settings) vs. provideLuxonDatetimeAdapter() (same) Moment works but Luxon doesn't.