aboutsummaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorFuwn <[email protected]>2024-01-18 00:53:37 -0800
committerFuwn <[email protected]>2024-01-18 00:53:42 -0800
commit61468ca364c1b3e498aaf73aa5084afbc217df6e (patch)
treef9dae0764137cb229d220046c356375c07dc1804 /src/lib
parentfeat(airing): shorten countdown setting (diff)
downloaddue.moe-61468ca364c1b3e498aaf73aa5084afbc217df6e.tar.xz
due.moe-61468ca364c1b3e498aaf73aa5084afbc217df6e.zip
feat(airing): stack time units and re-add weeks
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/Media/Anime/Airing/time.ts46
1 files changed, 31 insertions, 15 deletions
diff --git a/src/lib/Media/Anime/Airing/time.ts b/src/lib/Media/Anime/Airing/time.ts
index 6ddc9aff..779e6e8c 100644
--- a/src/lib/Media/Anime/Airing/time.ts
+++ b/src/lib/Media/Anime/Airing/time.ts
@@ -19,7 +19,7 @@ export const airingTime = (
hour: 'numeric',
minute: '2-digit'
});
- let timeFrame;
+ let timeFrame = '';
let hours = null;
const shortenCountdown = get(settings).displayShortCountdown;
@@ -44,30 +44,46 @@ export const airingTime = (
if (minutes > 60) {
hours = minutes / 60;
- if (hours >= 24) {
- // let weeks = Math.floor(Math.floor(hours / 24) / 7);
+ if (hours > 24) {
+ let weeks = Math.floor(hours / 24) / 7;
few = false;
- // if (weeks >= 1) {
- // weeks = Math.round(weeks);
+ if (weeks >= 1.5) {
+ weeks = Math.round(weeks);
- // timeFrame = `${weeks} week${weeks === 1 ? '' : 's'}`;
- // } else {
- const days = Math.round(Math.floor(hours / 24));
+ 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'}${
- days === 1 || shortenCountdown ? '' : 's'
- }`;
- // }
- } else
- timeFrame = `${hours.toFixed(1)}${shortenCountdown ? 'h' : ' hour'}${
+ timeFrame += `${days.toFixed(0)}${shortenCountdown ? 'd' : ' day'}${
+ days === 1 || shortenCountdown ? '' : 's'
+ }`;
+
+ if (residualHours > 0)
+ timeFrame += `${shortenCountdown ? '' : ' '}${residualHours}${
+ shortenCountdown ? 'h' : ' hour'
+ }${residualHours === 1 || shortenCountdown ? '' : 's'}`;
+ }
+ } else {
+ const residualMinutes = Math.round(minutes - Math.floor(hours) * 60);
+
+ timeFrame += `${hours.toFixed(0)}${shortenCountdown ? 'h' : ' hour'}${
hours === 1 || shortenCountdown ? '' : 's'
}`;
+
+ if (residualMinutes > 0)
+ timeFrame += `${shortenCountdown ? '' : ' '}${residualMinutes}${
+ shortenCountdown ? 'm' : ' minute'
+ }${residualMinutes === 1 || shortenCountdown ? '' : 's'}`;
+ }
} else {
minutes = Math.round(minutes);
- timeFrame = `${minutes}${shortenCountdown ? 'h' : ' minute'}${
+ timeFrame += `${minutes}${shortenCountdown ? 'm' : ' minute'}${
minutes === 1 || shortenCountdown ? '' : 's'
}`;
}