Open mj-jackson opened 3 years ago
I am having the same issue when using js-joda. Seems there is already a patch for it which has not yet been accepted, though. https://github.com/h2qutc/angular-material-components/pull/165
I wrote my own Luxon adapter using the moment.js adapter as a starting point, and it seems to be working as intended. It's not published in npm (yet), but you can find the code here: https://github.com/ensnared/luxon-datetime-adapter
To answer your question though, you can set the values in Luxon but you have to access the internal properties directly, like this:
setHour(date: DateTime, value: number): void {
date['c'].hour = value;
}
setMinute(date: DateTime, value: number): void {
date['c'].minute = value;
}
setSecond(date: DateTime, value: number): void {
date['c'].second = value;
}
Bump. The API expects a mutable date, but Luxon's dates are immutable by design. DateTime reference
Since both the native and Moment adapters are not recommended, this is really hampering the usability of this library.
I forked this a while back to allow for luxon compatibility. It isn't up to date w/ Angular Material 15 yet.
Since moment js itself lists points why not to use it anymore we decided to go with luxon for this project I am working on.
I searched but I feel there is no NgxMatLuxonDateModule yet so I tried to write my own luxon adapter based on the luxon adapter of the MatDatePicker. You can implement an abstract class in typescript so I did the following:
export class MyDateAdapter extends LuxonDateAdapter implements NgxMatDateAdapter<DateTime> {}
Having all the functionality of the LuxonDateAdapter only to extend it to match the NgxMatDateAdapter. But I am having trouble setting the new time.
Since the NgxMatDateAdapter uses setters which seem to count on a mutable object-reference DATE I cannot update the Luxon DateTime object since it is immutable and the DateTime.set method always returns a newly constructed object.
Am I missing something?