From dac0d09167b589948d5060f2b804060b8689f77f Mon Sep 17 00:00:00 2001 From: minie4 Date: Sun, 11 Jun 2023 23:54:18 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20issues=20with=20UTC=20time?= =?UTF-8?q?=20handling?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Using `.setUTCHours` can cause the day to shift at specific times --- src/components/day-carousel.vue | 4 ++-- src/components/history-list.vue | 22 ++++++++++++++-------- src/components/substitution-list.vue | 22 ++++++++++++++-------- src/store.js | 4 ++-- src/util.js | 12 ++++++++---- 5 files changed, 40 insertions(+), 24 deletions(-) diff --git a/src/components/day-carousel.vue b/src/components/day-carousel.vue index df34c74..c2c99d5 100644 --- a/src/components/day-carousel.vue +++ b/src/components/day-carousel.vue @@ -3,7 +3,7 @@ import { selectedDate, changeDate, changeDay } from "@/store"; import { Swiper, SwiperSlide } from "swiper/vue"; import { Virtual } from "swiper"; import { ref, watch } from "vue"; -import { getDateSkippingWeekend } from "@/util"; +import { getDateSkippingWeekend, setUTCMidnight } from "@/util"; import ScrollableContainer from "@/components/scrollable-container.vue"; defineProps({ @@ -89,7 +89,7 @@ watch(changeDay, (change) => { changeDay.value = 0; }); watch(changeDate, (date) => { - slideToDate(new Date(date.setUTCHours(0, 0, 0, 0))); + slideToDate(setUTCMidnight(date)); }); diff --git a/src/components/history-list.vue b/src/components/history-list.vue index fbd79c6..d3dc2ca 100644 --- a/src/components/history-list.vue +++ b/src/components/history-list.vue @@ -1,5 +1,5 @@