From 482891e39b2588ffe26d9d2da4123ff8d2f1a320 Mon Sep 17 00:00:00 2001 From: capitanwesler Date: Tue, 13 Apr 2021 10:07:06 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=A2=20Changing=20the=20from=20how=20it?= =?UTF-8?q?=20takes=20the=20nextEpisode?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/util.ts | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/utils/util.ts b/src/utils/util.ts index df10448..8303446 100644 --- a/src/utils/util.ts +++ b/src/utils/util.ts @@ -576,12 +576,28 @@ export const monoschinosInfo = async ( if (!extraInfo.aired.to) { if (airDay.hasOwnProperty(extraInfo.broadcast)) { - for ( - let i = broadCastDate.getDay(); - i < airDay[extraInfo.broadcast]; - i++ - ) { + console.log(broadCastDate.getDay(), airDay[extraInfo.broadcast]); + if (broadCastDate.getDay() < airDay[extraInfo.broadcast]) { + for ( + let i = broadCastDate.getDay(); + i < airDay[extraInfo.broadcast]; + i++ + ) { + broadCastDate.setDate(broadCastDate.getDate() + 1); + } + } else { + let counter = broadCastDate.getDay() + 1; + + /* Adding one because of the day */ broadCastDate.setDate(broadCastDate.getDate() + 1); + + while (counter !== airDay[extraInfo.broadcast]) { + if (counter === 7) { + counter = 0; + } + broadCastDate.setDate(broadCastDate.getDate() + 1); + counter++; + } } dd = broadCastDate.getDate();