Is this a regression?
The previous version in which this bug was not present was
No response
Description
When using the timepicker with the Luxon date adapter, the DateTime's zone is ignored after setting a new value with the timepicker.
The luxon adapter is configured with useUtc: false.
The timepicker is correctly calling only the setTime on the previous valid value:
| toAssign=target ? adapter.setTime(target,hours,minutes,seconds) : selection; |
But the luxon data adapter is cloning the value without preserving the timezone.
| returnLuxonDateTime.fromObject(date.toObject(),this._getOptions()); |
| zone: this._useUTC ? 'utc' : undefined, |
I think in this case the timezone shouldn't be set to undefined, but to the previous valid value's timezone.
I could fix the issue with a custom date adapter with overriding the clone method:
exportclassCustomLuxonDateAdapterextendsLuxonDateAdapter{overrideclone(date: DateTime): DateTime{returnDateTime.fromObject(date.toObject(),{zone: date.zone,}asDateTimeOptions);}}Reproduction
StackBlitz link: https://stackblitz.com/edit/stackblitz-starters-hy9xclwv?file=src%2Fmain.ts
Steps to reproduce:
- Use @angular/material-luxon-adapter with useUtc: false
- Create a luxon DateTime object with a custom timezone (not your local timezone)
- Set a new time on the timepicker
- The value's zone will be set to your local timezone.
On the stackblitz example, I printed out the zone for easier checking.
Expected Behavior
The value's timezone should be not ignored on cloning a DateTime object.
Actual Behavior
The value's timezone is set to undefined on cloning a DateTime object.
Environment
- Angular: 22
- CDK/Material: 22
- Browser(s): doesn't matter, but latest Chrome
- Operating System (e.g. Windows, macOS, Ubuntu): Windows
Is this a regression?
The previous version in which this bug was not present was
No response
Description
When using the timepicker with the Luxon date adapter, the DateTime's zone is ignored after setting a new value with the timepicker.
The luxon adapter is configured with useUtc: false.
The timepicker is correctly calling only the setTime on the previous valid value:
components/src/material/timepicker/timepicker-input.ts
Line 404 in 43a87a4
But the luxon data adapter is cloning the value without preserving the timezone.
components/src/material-luxon-adapter/adapter/luxon-date-adapter.ts
Line 137 in 43a87a4
components/src/material-luxon-adapter/adapter/luxon-date-adapter.ts
Line 326 in 43a87a4
I think in this case the timezone shouldn't be set to undefined, but to the previous valid value's timezone.
I could fix the issue with a custom date adapter with overriding the clone method:
Reproduction
StackBlitz link: https://stackblitz.com/edit/stackblitz-starters-hy9xclwv?file=src%2Fmain.ts
Steps to reproduce:
On the stackblitz example, I printed out the zone for easier checking.
Expected Behavior
The value's timezone should be not ignored on cloning a DateTime object.
Actual Behavior
The value's timezone is set to undefined on cloning a DateTime object.
Environment