From 3301aefc11d7c47093aadd7d0bcd5aae1913b66c Mon Sep 17 00:00:00 2001 From: Javier Bullrich Date: Wed, 31 Jul 2024 10:55:42 +0200 Subject: [PATCH] Applied CodeRabitt's suggestion Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- src/lib/components/Status.svelte | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/lib/components/Status.svelte b/src/lib/components/Status.svelte index d3aa5da..a1cd9e4 100644 --- a/src/lib/components/Status.svelte +++ b/src/lib/components/Status.svelte @@ -4,10 +4,8 @@ export let name: string; export let statuses: Status[]; - function calculateDifferenceInDays(firstDate: Date, secondDate: Date): number { - const oneDay = 24 * 60 * 60 * 1000; // hours*minutes*seconds*milliseconds - return Math.round(Math.abs((+firstDate - +secondDate) / oneDay)) + 1; - } + const calculateDifferenceInDays = (firstDate: Date, secondDate: Date): number => + Math.ceil(Math.abs(+firstDate - +secondDate) / (1000 * 60 * 60 * 24)); let message = 'Lacking historical data'; let lastStatus: Status = { status: StatusCode.ERROR, date: new Date() };