From 1fee9bf0c2c8777087bf986b6bf2baae5d061ab0 Mon Sep 17 00:00:00 2001 From: minie4 Date: Thu, 2 Jun 2022 16:46:43 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Skip=20weekend=20days=20on=20the=20?= =?UTF-8?q?timetable?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/date-selector.vue | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/components/date-selector.vue b/src/components/date-selector.vue index 5c3c784..46c0485 100644 --- a/src/components/date-selector.vue +++ b/src/components/date-selector.vue @@ -3,13 +3,24 @@ import { selectedDate, selectedDay } from "../store"; import { dayNames } from "../definitions"; import dayjs from "dayjs"; import ArrowIcon from "./icons/arrow-icon.vue"; + +function nextDay() { + var newDate = dayjs(selectedDate.value).add(1, "day"); + // Skip weekend + if (newDate.day() == 6) newDate = newDate.add(2, "day"); + selectedDate.value = newDate.toDate(); +} +function previousDay() { + var newDate = dayjs(selectedDate.value).subtract(1, "day"); + // Skip weekend + if (newDate.day() == 0) newDate = newDate.subtract(2, "day"); + selectedDate.value = newDate.toDate(); +}