Improved airing dates in anime view
This commit is contained in:
parent
f4c1800244
commit
58e7c8a34d
@ -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.
|
||||
|
@ -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 {
|
||||
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"
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user