diff options
| author | Fuwn <[email protected]> | 2023-12-16 18:55:34 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2023-12-16 18:55:34 -0800 |
| commit | 14836d25bc582f5d289af3a92b96ddead02d6bfb (patch) | |
| tree | bc474a662a35de47816e03076e0579f39b34f92c /src/lib | |
| parent | feat(anime): subtitle countdown (diff) | |
| download | due.moe-14836d25bc582f5d289af3a92b96ddead02d6bfb.tar.xz due.moe-14836d25bc582f5d289af3a92b96ddead02d6bfb.zip | |
fix(anime): adjust airing exact time
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/Media/anime.ts | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/src/lib/Media/anime.ts b/src/lib/Media/anime.ts index b9227562..4ad23f56 100644 --- a/src/lib/Media/anime.ts +++ b/src/lib/Media/anime.ts @@ -74,6 +74,11 @@ const findClosestMatch = (times: Time[], titles: string[]) => { export const airingTime = (anime: Media, subsPlease: SubsPlease, upcoming = false) => { const airingAt = anime.nextAiringEpisode?.airingAt; let untilAiring; + let time = new Date(airingAt ? airingAt * 1000 : 0).toLocaleTimeString([], { + hour12: !settings.get().display24HourTime, + hour: 'numeric', + minute: '2-digit' + }); if (get(settings).displayNativeCountdown) { untilAiring = airingAt ? Math.round((airingAt - Date.now() / 1000) * 100) / 100 : undefined; @@ -92,23 +97,24 @@ export const airingTime = (anime: Media, subsPlease: SubsPlease, upcoming = fals } } - const time: Time | null = findClosestMatch(times, [ + const foundTime: Time | null = findClosestMatch(times, [ anime.title.romaji, anime.title.english, ...anime.synonyms ]); - if (time) untilAiring = secondsUntil((time as Time).time, (time as Time).day); - else + if (foundTime) { + untilAiring = secondsUntil((foundTime as Time).time, (foundTime as Time).day); + time = new Date(Date.now() + untilAiring * 1000).toLocaleTimeString([], { + hour12: !settings.get().display24HourTime, + hour: 'numeric', + minute: '2-digit' + }); + } else untilAiring = airingAt ? Math.round((airingAt - Date.now() / 1000) * 100) / 100 : undefined; } let timeFrame; - const time = new Date(airingAt ? airingAt * 1000 : 0).toLocaleTimeString([], { - hour12: !settings.get().display24HourTime, - hour: 'numeric', - minute: '2-digit' - }); let hours = null; if ( |