From 037b62bab5b5875d0461a75f6ac268ebb4b766cf Mon Sep 17 00:00:00 2001 From: Richard Wall Date: Sat, 10 Jul 2010 11:07:01 +0100 Subject: Allow user configurable timezone offset --- jarmon.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'jarmon.js') diff --git a/jarmon.js b/jarmon.js index ffcb177..62bf51c 100644 --- a/jarmon.js +++ b/jarmon.js @@ -75,13 +75,12 @@ jarmon.localTimeFormatter = function (v, axis) { "year": 365.2425 * 24 * 60 * 60 * 1000 }; - // Offset the input timestamp for local time - var offset = new Date().getTimezoneOffset() * 60 * 1000; - var d = new Date(v - offset); + // Offset the input timestamp by the user defined amount + var d = new Date(v + axis.options.tzoffset); // first check global format if (axis.options.timeformat != null) - return $.plot.formatDate(d, opts.timeformat, opts.monthNames); + return $.plot.formatDate(d, axis.options.timeformat, axis.options.monthNames); var t = axis.tickSize[0] * timeUnitSize[axis.tickSize[1]]; var span = axis.max - axis.min; @@ -660,8 +659,13 @@ jarmon.ChartCoordinator.prototype.update = function() { **/ var startTime = new Date(this.ui[0].startTime.value); var endTime = new Date(this.ui[0].endTime.value); + var tzoffset = parseInt(this.ui[0].tzoffset.value) * 60 * 60 * 1000; + + this.rangePreviewOptions.xaxis.tzoffset = tzoffset; + var chartsLoading = []; for(var i=0; i 0) { + tzoffset = '+' + tzoffset; + } + this.ui[0].tzoffset.value = tzoffset; return this.setTimeRange(new Date(new Date().getTime()-1*60*60*1000), new Date()); }; -- cgit v1.2.3