Engine.SimpleTimeRemaining = class { constructor(seconds /*int*/) { this.expireTimeMS = 0; this.initialSecondsRemaining = 0; this.timeRemaining = seconds; } //Time Remaining in Seconds. get timeRemaining() { return Math.max(0, (this.expireTimeMS - Engine.Utils.getTimer()) / 1000); } set timeRemaining(value) { this.initialSecondsRemaining = value; this.expireTimeMS = Engine.Utils.getTimer() + value * 1000; } // if you get the time Remaining of a bunch of items in a list, // the items after will have less time remaining because of the processing time // this happens for week 10 of challenges // so pass in what the current time to measure is. getTimeRemaining(currentTime) { return Math.max(0, (this.expireTimeMS - currentTime) / 1000); } set baseTime(value) { this.expireTimeMS = value + this.initialSecondsRemaining * 1000; } }