Improved airing dates in anime view

This commit is contained in:
Eduard Urbach 2017-06-29 09:02:06 +02:00
parent f4c1800244
commit 58e7c8a34d
2 changed files with 21 additions and 9 deletions

View File

@ -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.

View File

@ -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"
}
}