From 35fb06c3451a67cb8b57e26392f63bd21054e262 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Thu, 24 Mar 2022 10:01:04 +0100 Subject: [PATCH] Pass the date to getTimezoneOffset() so that the DST is accounted for See https://github.com/marnusw/date-fns-tz#gettimezoneoffset Closes #1069 Signed-off-by: Thomas Citharel --- js/src/components/Event/EventFullDate.vue | 11 +++++++---- js/src/views/Event/Edit.vue | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/js/src/components/Event/EventFullDate.vue b/js/src/components/Event/EventFullDate.vue index 8708993ad..4ca50ee96 100644 --- a/js/src/components/Event/EventFullDate.vue +++ b/js/src/components/Event/EventFullDate.vue @@ -169,17 +169,20 @@ export default class EventFullDate extends Vue { isSameDay(): boolean { const sameDay = - new Date(this.beginsOn).toDateString() === - new Date(this.endsOn).toDateString(); + this.beginsOnDate.toDateString() === new Date(this.endsOn).toDateString(); return this.endsOn !== undefined && sameDay; } + get beginsOnDate(): Date { + return new Date(this.beginsOn); + } + get differentFromUserTimezone(): boolean { return ( !!this.timezone && !!this.userActualTimezone && - getTimezoneOffset(this.timezone) !== - getTimezoneOffset(this.userActualTimezone) && + getTimezoneOffset(this.timezone, this.beginsOnDate) !== + getTimezoneOffset(this.userActualTimezone, this.beginsOnDate) && this.timezone !== this.userActualTimezone ); } diff --git a/js/src/views/Event/Edit.vue b/js/src/views/Event/Edit.vue index 9fba5a386..3f2295d49 100644 --- a/js/src/views/Event/Edit.vue +++ b/js/src/views/Event/Edit.vue @@ -1300,7 +1300,7 @@ export default class EditEvent extends Vue { tzOffset(date: Date): number { if (this.timezone && date) { const eventUTCOffset = getTimezoneOffset(this.timezone, date); - const localUTCOffset = getTimezoneOffset(this.userActualTimezone); + const localUTCOffset = getTimezoneOffset(this.userActualTimezone, date); return (eventUTCOffset - localUTCOffset) / (60 * 1000); } return 0;