diff --git a/libs/designsystem/calendar/src/calendar.component.spec.ts b/libs/designsystem/calendar/src/calendar.component.spec.ts index 6033efeec5..5fa2d3cf1e 100644 --- a/libs/designsystem/calendar/src/calendar.component.spec.ts +++ b/libs/designsystem/calendar/src/calendar.component.spec.ts @@ -879,6 +879,16 @@ describe('CalendarComponent', () => { expect(spectator.component.selectedDate).toEqual(localMidnightDate('1997-08-14')); }); + + it('should set focussedDate to midnight of focussed date when using UTC', () => { + spectator.setInput('timezone', 'UTC'); + spectator.setInput('selectedDate', utcMidnightDate('1997-08-29')); + + const focussedDay = spectator.query('.focussed'); + spectator.dispatchKeyboardEvent(focussedDay, 'keydown', 'ArrowRight'); + + expect(spectator.component['focussedDate']).toEqual(utcMidnightDate('1997-08-30')); + }); }); // constants and utility functions diff --git a/libs/designsystem/calendar/src/calendar.component.ts b/libs/designsystem/calendar/src/calendar.component.ts index 0054a1d8a6..d7d4dca6ff 100644 --- a/libs/designsystem/calendar/src/calendar.component.ts +++ b/libs/designsystem/calendar/src/calendar.component.ts @@ -547,6 +547,8 @@ export class CalendarComponent implements OnInit, OnChanges { private focusDate(newDate: Date | null) { if (!newDate) return; + newDate = this.normalizeDate(newDate); + if (this.timezone === 'UTC') { newDate = zonedTimeToUtc(this.subtractTimezoneOffset(newDate), this.timeZoneName); }