Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/material-luxon-adapter/adapter/luxon-date-adapter.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,22 @@ describe('LuxonDateAdapter', () => {
expect(clone.toISO()).toEqual(date.toISO());
});

it('should respect timezone on clone', () => {
const dateLocal = DateTime.local(2017, JAN, 1);
const dateInCet = dateLocal.setZone('Europe/Budapest');
const cloneInCet = adapter.clone(dateInCet);
const dateInPst = dateLocal.setZone('America/Los_Angeles');
const cloneInPst = adapter.clone(dateInPst);

expect(cloneInCet).not.toBe(dateInCet);
expect(cloneInCet.toISO()).toEqual(dateInCet.toISO());
expect(cloneInCet.zone).toEqual(dateInCet.zone);

expect(cloneInPst).not.toBe(dateInPst);
expect(cloneInPst.toISO()).toEqual(dateInPst.toISO());
expect(cloneInPst.zone).toEqual(dateInPst.zone);
});

it('should compare dates', () => {
expect(
adapter.compareDate(DateTime.local(2017, JAN, 1), DateTime.local(2017, JAN, 2)),
Expand Down
5 changes: 4 additions & 1 deletion src/material-luxon-adapter/adapter/luxon-date-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,10 @@ export class LuxonDateAdapter extends DateAdapter<LuxonDateTime> {
}

clone(date: LuxonDateTime): LuxonDateTime {
return LuxonDateTime.fromObject(date.toObject(), this._getOptions());
return LuxonDateTime.fromObject(date.toObject(), {
...this._getOptions(),
zone: date.zone,
});
}

createDate(year: number, month: number, date: number): LuxonDateTime {
Expand Down
Loading