Switched to use Date.now()
This commit is contained in:
parent
f96d8f3f8b
commit
85b51a378a
@ -7,14 +7,14 @@ function CurrencyController(options) {
|
||||
var refresh = options.currencyRefresh || CurrencyController.DEFAULT_CURRENCY_DELAY;
|
||||
this.currencyDelay = refresh * 60000;
|
||||
this.bitstampRate = 0;
|
||||
this.timestamp = + new Date();
|
||||
this.timestamp = Date.now();
|
||||
}
|
||||
|
||||
CurrencyController.DEFAULT_CURRENCY_DELAY = 10;
|
||||
|
||||
CurrencyController.prototype.index = function(req, res) {
|
||||
var self = this;
|
||||
var currentTime = + new Date();
|
||||
var currentTime = Date.now();
|
||||
if (self.bitstampRate === 0 || currentTime >= (self.timestamp + self.currencyDelay)) {
|
||||
self.timestamp = currentTime;
|
||||
request('https://www.bitstamp.net/api/ticker/', function(err, response, body) {
|
||||
|
||||
@ -43,7 +43,7 @@ describe('Currency', function() {
|
||||
};
|
||||
var currency = new TestCurrencyController({node: node});
|
||||
currency.bitstampRate = 220.20;
|
||||
currency.timestamp = new Date() - 61000 * CurrencyController.DEFAULT_CURRENCY_DELAY;
|
||||
currency.timestamp = Date.now() - 61000 * CurrencyController.DEFAULT_CURRENCY_DELAY;
|
||||
var req = {};
|
||||
var res = {
|
||||
jsonp: function(response) {
|
||||
@ -67,7 +67,7 @@ describe('Currency', function() {
|
||||
};
|
||||
var currency = new TestCurrencyController({node: node});
|
||||
currency.bitstampRate = 237.90;
|
||||
currency.timestamp = new Date() - 65000 * CurrencyController.DEFAULT_CURRENCY_DELAY;
|
||||
currency.timestamp = Date.now() - 65000 * CurrencyController.DEFAULT_CURRENCY_DELAY;
|
||||
var req = {};
|
||||
var res = {
|
||||
jsonp: function(response) {
|
||||
@ -93,7 +93,7 @@ describe('Currency', function() {
|
||||
};
|
||||
var currency = new TestCurrencyController({node: node});
|
||||
currency.bitstampRate = 237.90;
|
||||
currency.timestamp = + new Date();
|
||||
currency.timestamp = Date.now();
|
||||
var req = {};
|
||||
var res = {
|
||||
jsonp: function(response) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user