Skip to content

Instantly share code, notes, and snippets.

Avatar

Nils-Helge Garli Hegvik nilsga

  • Biztek AS
  • Trondheim, Norway
View GitHub Profile
View gist:5406761
function MatchClock(match, callback) {
this.currentHalf = match.currentHalf || 0;
this.currentHalfOffset = match.currentHalfOffset || 0;
this.startTime = new Date(match.startTime);
this.paused = match.paused;
this.clockDiff = new Date().getTime() - new Date(match.serverTime).getTime();
this.callback = callback;
if(typeof this.paused !== "undefined" && !this.paused) {
this.start(this.callback);
}