1
0
Fork 0
mirror of https://framagit.org/framasoft/mobilizon.git synced 2024-12-25 09:22:22 +00:00

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 <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2022-03-24 10:01:04 +01:00
parent 72ed766f26
commit 35fb06c345
No known key found for this signature in database
GPG key ID: A061B9DDE0CA0773
2 changed files with 8 additions and 5 deletions

View file

@ -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
);
}

View file

@ -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;