isso/isso/js/app/globals.js
2014-03-28 11:48:29 +01:00

21 lines
482 B
JavaScript

define(function() {
"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; }) / this.values.length);
};
return {
offset: new Offset()
};
});