Move timezone offset calculation out of for loop.

This commit is contained in:
Michael Stenta 2018-11-10 09:55:24 -05:00
parent cec49722b0
commit c661954e36
1 changed files with 3 additions and 1 deletions

View File

@ -2,6 +2,9 @@
Drupal.behaviors.farm_area_generate = {
attach: function (context, settings) {
// Calculate the timezone offset in milliseconds.
var tzoffset = (new Date()).getTimezoneOffset() * 60000;
// Iterate through the graphs.
for (var i = 0; i < settings.farm_sensor_listener.graphs.length; i++) {
@ -16,7 +19,6 @@
// Iterate through the data and put it into the arrays.
for (var j = 0; j < data.length; j++) {
var tzoffset = (new Date()).getTimezoneOffset() * 60000;
var date = new Date((data[j].timestamp * 1000) - tzoffset).toISOString();
dates.push(date);
values.push(data[j][name]);