summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Wall <richard@aziz>2010-07-10 11:07:01 +0100
committerRichard Wall <richard@aziz>2010-07-10 11:07:01 +0100
commit037b62bab5b5875d0461a75f6ac268ebb4b766cf (patch)
tree1924687e018745750a0d990cbe61bcdb264462a2
parente04435a8179b766cc394a02ed1e22e80f21a7aee (diff)
Allow user configurable timezone offset
-rw-r--r--index.html1
-rw-r--r--jarmon.js19
2 files changed, 16 insertions, 4 deletions
diff --git a/index.html b/index.html
index 426e7eb..b4e0ab8 100644
--- a/index.html
+++ b/index.html
@@ -145,6 +145,7 @@
<div>
<label>Start: <input type="date" name="startTime" /></label>
<label>End: <input type="date" name="endTime" /></label>
+ <label>UTC: <input type="text" name="tzoffset" size="2" /></label>
<input type="submit" value="Update" />
<input type="reset" value="Reset" />
</div>
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<this.charts.length; i++){
+ this.charts[i].options.xaxis.tzoffset = tzoffset;
// Don't render charts which are not currently visible
if(this.charts[i].template.is(':visible')) {
chartsLoading.push(
@@ -739,6 +743,13 @@ jarmon.ChartCoordinator.prototype.reset = function() {
/**
* Reset all charts and the input form to the default time range - last hour
**/
+
+ // Default timezone offset based on localtime
+ var tzoffset = -1 * new Date().getTimezoneOffset() / 60;
+ if(tzoffset > 0) {
+ tzoffset = '+' + tzoffset;
+ }
+ this.ui[0].tzoffset.value = tzoffset;
return this.setTimeRange(new Date(new Date().getTime()-1*60*60*1000),
new Date());
};