added timezone offset to headline

This commit is contained in:
Steffen Vogel 2011-07-22 11:44:40 +02:00
parent 989831c7a0
commit 139dc982cc
4 changed files with 12 additions and 12 deletions

View file

@ -83,7 +83,7 @@ Entity.prototype.loadData = function() {
success: function(json) {
this.data = json.data;
if (this.data.count > 0) {
if (this.data.tuples.length > 0) {
if (this.data.min[1] < vz.options.plot.yaxis.min) { // allow negative values for temperature sensors
vz.options.plot.yaxis.min = null;
}
@ -298,7 +298,7 @@ Entity.prototype.updateDOMRow = function() {
var delta = this.data.to - this.data.from;
var year = 365*24*60*60*1000;
if (this.data.count > 0) { // update statistics if data available
if (this.data.rows > 0) { // update statistics if data available
$('.min', row)
.text(vz.wui.formatNumber(this.data.min[1], true) + this.definition.unit)
.attr('title', $.plot.formatDate(new Date(this.data.min[0]), '%d. %b %y %h:%M:%S', vz.options.plot.xaxis.monthNames));

View file

@ -1238,13 +1238,9 @@
};
formatter = function (v, axis) {
if (opts.useLocalTime)
v -= new Date(v).getTimezoneOffset()*60000;
var d = new Date(v);
// first check global format
if (opts.timeformat != null)
return $.plot.formatDate(d, opts.timeformat, opts.monthNames);
return $.plot.formatDate(v, opts.timeformat, opts.monthNames, opts.useLocalTime);
var t = axis.tickSize[0] * timeUnitSize[axis.tickSize[1]];
var span = axis.max - axis.min;
@ -1270,7 +1266,7 @@
else
fmt = "%y";
return $.plot.formatDate(d, fmt, opts.monthNames);
return $.plot.formatDate(v, fmt, opts.monthNames, opts.useLocalTime);
};
}
else {
@ -2539,7 +2535,12 @@
$.plot.plugins = [];
// returns a string with the date d formatted according to fmt
$.plot.formatDate = function(d, fmt, monthNames) {
$.plot.formatDate = function(v, fmt, monthNames, tzOffset) {
if (tzOffset)
v -= new Date(v).getTimezoneOffset()*60000;
var d = new Date(v);
var leftPad = function(n) {
n = "" + n;
return n.length == 1 ? "0" + n : n;

View file

@ -33,7 +33,6 @@ vz.options = {
refresh: false,
minTimeout: 3000, // minimum refresh time in ms
defaultInterval: 24*60*60*1000, // 1 day
timezoneOffset: -(new Date().getTimezoneOffset() * 60000) // TODO add option with timezone dropdown
};
vz.options.plot = {

View file

@ -413,8 +413,8 @@ vz.wui.formatNumber = function(number, prefix) {
}
vz.wui.updateHeadline = function() {
var from = $.plot.formatDate(new Date(vz.options.plot.xaxis.min), '%d. %b %y %h:%M', vz.options.plot.xaxis.monthNames);
var to = $.plot.formatDate(new Date(vz.options.plot.xaxis.max), '%d. %b %y %h:%M', vz.options.plot.xaxis.monthNames);
var from = $.plot.formatDate(new Date(vz.options.plot.xaxis.min), '%d. %b %y %h:%M', vz.options.plot.xaxis.monthNames, true);
var to = $.plot.formatDate(new Date(vz.options.plot.xaxis.max), '%d. %b %y %h:%M', vz.options.plot.xaxis.monthNames, true);
$('#title').html(from + ' - ' + to);
}