"use strict";

var Offset = function() {
    this.values = [];
};

Offset.prototype.update = function(remoteTime) {
    this.values.push((new Date()).getTime() - remoteTime.getTime());
};

Offset.prototype.localTime = function() {
    return new Date((new Date()).getTime() - this.values.reduce(
        function(a, b) { return a + b; }, 0) / this.values.length);
};

var offset = new Offset();

module.exports = {
    offset: offset,
}
