diff --git a/pages/anime/anime.pixy b/pages/anime/anime.pixy index 75972cd1..b412156e 100644 --- a/pages/anime/anime.pixy +++ b/pages/anime/anime.pixy @@ -158,7 +158,7 @@ component Anime(anime *arn.Anime, tracks []*arn.SoundTrack, user *arn.User, epis td.episode-actions a(href="https://translate.google.com/#ja/en/" + episode.Title.Japanese, target="_blank", rel="noopener") RawIcon("google") - td.episode-airing-date-start(title=episode.AiringDate.StartTimeHuman())= episode.AiringDate.StartDateHuman() + td.episode-airing-date-start.utc-date(data-start-date=episode.AiringDate.Start, data-end-date=episode.AiringDate.End, data-episode-number=episode.Number)= episode.AiringDate.StartDateHuman() //- h3.anime-section-name Reviews //- p Coming soon. diff --git a/scripts/AnimeNotifier.ts b/scripts/AnimeNotifier.ts index 474a1513..2b38c29a 100644 --- a/scripts/AnimeNotifier.ts +++ b/scripts/AnimeNotifier.ts @@ -92,18 +92,30 @@ export class AnimeNotifier { m = endDate.getMinutes() let endTime = (h <= 9 ? "0" + h : h) + ":" + (m <= 9 ? "0" + m : m) - let dayDifference = Math.round(Math.abs((startDate.getTime() - now.getTime()) / oneDay)) + let dayDifference = Math.round((startDate.getTime() - now.getTime()) / oneDay) let dayInfo = dayNames[startDate.getDay()] + ", " + monthNames[startDate.getMonth()] + " " + startDate.getDate() - if(dayDifference > 1) { - element.innerText = dayDifference + " day" + (dayDifference == 1 ? "" : "s") - } else if(dayDifference == 1) { - element.innerText = "Tomorrow" - } else { - element.innerText = "Today" + let airingVerb = "will be airing" + + switch(dayDifference) { + case 0: + element.innerText = "Today" + case 1: + element.innerText = "Tomorrow" + case -1: + element.innerText = "Yesterday" + default: + let text = Math.abs(dayDifference) + " days" + + if(dayDifference < 0) { + text += " ago" + airingVerb = "aired" + } else { + element.innerText = text + } } - element.title = "Episode " + element.dataset.episodeNumber + " will be airing " + startTime + " - " + endTime + " your time" + element.title = "Episode " + element.dataset.episodeNumber + " " + airingVerb + " " + startTime + " - " + endTime + " your time" } }