From 593fcc1349059e17ce5db780deeacc75c8049058 Mon Sep 17 00:00:00 2001 From: Clarence Chan Date: Sun, 29 Sep 2024 13:05:50 -0400 Subject: [PATCH] Fix bug where number of hours early/prelims start before main could be negative --- index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index dcfc5cfd..790ce4a7 100644 --- a/index.js +++ b/index.js @@ -52,7 +52,7 @@ async function createICS() { if (event.prelimsTime) { let prelimsTime = new Date(parseInt(event.prelimsTime) * 1000); let hoursAgo = (date - prelimsTime) / 1000 / 60 / 60; - description += ` (${hoursAgo} hrs before Main)`; + if (hoursAgo > 0) description += ` (${hoursAgo} hrs before Main)`; } description += `\n--------------------\n${event.prelims.join("\n")}\n`; } @@ -63,7 +63,7 @@ async function createICS() { parseInt(event.earlyPrelimsTime) * 1000 ); let hoursAgo = (date - earlyPrelimsTime) / 1000 / 60 / 60; - description += ` (${hoursAgo} hrs before Main)`; + if (hoursAgo > 0) description += ` (${hoursAgo} hrs before Main)`; } description += `\n--------------------\n${event.earlyPrelims.join( "\n"