code: function WallClock(interval) {
    var self = this, at, mark = null;
  
    self.at = function() {
      return at;
    };
  
    self.init = function() {
      at = new Date().getTime();
      mark = at + interval;
      return at;
    };
  
    self.inc = function() {
      at = new Date().getTime();
    };
  
    self.tick = function() {
      if (mark === null) {
        throw "clock was not initialized";
      }
      self.inc();
  
      return ((at - mark) >= 0);
    };
  
    self.tock = function(elapsed) {
      var d = at - elapsed;
      if ( d >= interval) {
        mark += interval;
        return true;
      }
      return false;
    };
  }
docs: Wall clock. Watch out for NTP/PTP shenanigans