MCPcopy Create free account
hub / github.com/codecombat/codecombat / refreshTournamentTime

Method refreshTournamentTime

app/views/ladder/LadderView.js:288–304  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

286 }
287
288 refreshTournamentTime () {
289 if (!(this.tournament != null ? this.tournament.get('endDate') : undefined)) { return }
290 const resultsDate = this.tournament.get('resultsDate') || this.tournament.get('endDate')
291 const currentTime = Date.now() + (this.timeOffset != null ? this.timeOffset : 0)
292 this.tournamentTimeElapsed = currentTime - new Date(this.tournament.get('startDate'))
293 this.tournamentTimeLeft = new Date(this.tournament.get('endDate')) - currentTime
294 this.tournamentResultsTimeLeft = new Date(resultsDate) - currentTime
295 const tournamentStartDate = new Date(currentTime - this.tournamentTimeElapsed)
296 const tournamentEndDate = new Date(currentTime + this.tournamentTimeLeft)
297 const tournamentResultsDate = new Date(currentTime + this.tournamentResultsTimeLeft)
298 this.tournamentTimeElapsedString = moment(tournamentStartDate).fromNow()
299 this.tournamentTimeLeftString = moment(tournamentEndDate).fromNow()
300 this.tournamentResultsTimeLeftString = moment(tournamentResultsDate).fromNow()
301 this.$('#tournament-time-elapsed').text(this.tournamentTimeElapsedString)
302 this.$('#tournament-time-left').text(this.tournamentTimeLeftString)
303 return this.$('#tournament-results-time-left').text(this.tournamentResultsTimeLeftString)
304 }
305
306 afterRender () {
307 let hash

Callers 1

checkTournamentCloseMethod · 0.95

Calls 1

getMethod · 0.45

Tested by

no test coverage detected