diff options
| -rw-r--r-- | src/lib/Media/Anime/Airing/AiringTime.svelte | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/src/lib/Media/Anime/Airing/AiringTime.svelte b/src/lib/Media/Anime/Airing/AiringTime.svelte index 57e016da..f4512d4c 100644 --- a/src/lib/Media/Anime/Airing/AiringTime.svelte +++ b/src/lib/Media/Anime/Airing/AiringTime.svelte @@ -63,29 +63,34 @@ hours = minutes / 60; if (hours > 24) { - let weeks = Math.floor(hours / 24) / 7; + const days = Math.floor(hours / 24); + const weeks = Math.floor(days / 7); few = false; if (weeks >= 1.5) { - weeks = Math.round(weeks); - timeFrame = `${weeks}${shortenCountdown ? 'w' : ' week'}${ weeks === 1 || shortenCountdown ? '' : 's' }`; - } else { - const days = Math.round(Math.floor(hours / 24)); - const residualHours = Math.floor(hours - days * 24); - timeFrame += `${days.toFixed(0)}${shortenCountdown ? 'd' : ' day'}${ + const residualDays = days % 7; + + if (residualDays > 0) + timeFrame += `${shortenCountdown ? '' : ' '}${residualDays}${ + shortenCountdown ? 'd' : ' day' + }${residualDays === 1 || shortenCountdown ? '' : 's'}`; + } else { + timeFrame += `${days}${shortenCountdown ? 'd' : ' day'}${ days === 1 || shortenCountdown ? '' : 's' }`; - - if (residualHours > 0) - timeFrame += `${shortenCountdown ? '' : ' '}${residualHours}${ - shortenCountdown ? 'h' : ' hour' - }${residualHours === 1 || shortenCountdown ? '' : 's'}`; } + + const residualHours = Math.floor(hours - days * 24); + + if (residualHours > 0) + timeFrame += `${shortenCountdown ? '' : ' '}${residualHours}${ + shortenCountdown ? 'h' : ' hour' + }${residualHours === 1 || shortenCountdown ? '' : 's'}`; } else { const residualMinutes = Math.round(minutes - Math.floor(hours) * 60); |