зеркало из https://github.com/mozilla/hawk.git
Merge pull request #110 from MathieuLoutre/fix-offset
Fix time calculation. Stop clearing offset when setting storage.
This commit is contained in:
Коммит
dd538056e2
|
@ -60,7 +60,7 @@ hawk.client = {
|
|||
|
||||
// Application time
|
||||
|
||||
var timestamp = options.timestamp || Math.floor((hawk.utils.now() + (options.localtimeOffsetMsec || 0)) / 1000)
|
||||
var timestamp = options.timestamp || hawk.utils.now(options.localtimeOffsetMsec);
|
||||
|
||||
// Validate credentials
|
||||
|
||||
|
@ -229,7 +229,7 @@ hawk.client = {
|
|||
|
||||
// Application time
|
||||
|
||||
var timestamp = options.timestamp || Math.floor((hawk.utils.now() + (options.localtimeOffsetMsec || 0)) / 1000)
|
||||
var timestamp = options.timestamp || hawk.utils.now(options.localtimeOffsetMsec);
|
||||
|
||||
// Validate credentials
|
||||
|
||||
|
@ -359,8 +359,8 @@ hawk.utils = {
|
|||
|
||||
setStorage: function (storage) {
|
||||
|
||||
var ntpOffset = hawk.utils.getNtpOffset() || 0;
|
||||
hawk.utils.storage = storage;
|
||||
var ntpOffset = hawk.utils.getNtpOffset() || 0;
|
||||
hawk.utils.setNtpOffset(ntpOffset);
|
||||
},
|
||||
|
||||
|
@ -380,9 +380,9 @@ hawk.utils = {
|
|||
return parseInt(hawk.utils.storage.getItem('hawk_ntp_offset') || '0', 10);
|
||||
},
|
||||
|
||||
now: function () {
|
||||
now: function (localtimeOffsetMsec) {
|
||||
|
||||
return (new Date()).getTime() + hawk.utils.getNtpOffset();
|
||||
return Math.floor(((new Date()).getTime() + (localtimeOffsetMsec || 0)) / 1000) + hawk.utils.getNtpOffset();
|
||||
},
|
||||
|
||||
escapeHeaderAttribute: function (attribute) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче