From 688c21cd94d9ddc583bb07bc3168661babb3945e Mon Sep 17 00:00:00 2001 From: Aaron Bassett Date: Tue, 8 Apr 2014 09:56:00 -0400 Subject: [PATCH] added little workraround for graphites timezones/DST failures --- src/app/components/settings.js | 12 +++++++++++- src/config.sample.js | 1 + 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/app/components/settings.js b/src/app/components/settings.js index 18fbf5e48a6..be845b0c722 100644 --- a/src/app/components/settings.js +++ b/src/app/components/settings.js @@ -24,7 +24,7 @@ function (_, crypto) { default_route : '/dashboard/file/default.json', grafana_index : 'grafana-dash', elasticsearch_all_disabled : false, - timezoneOffset : null, + timezoneOffset : 'auto', }; // This initializes a new hash on purpose, to avoid adding parameters to @@ -59,6 +59,16 @@ function (_, crypto) { }; } + if (settings.timezoneOffset === 'auto' ) + { + //this hack is to deal with graphites poor tz support. It doesn't like + // DST, so we're gonna make a january (non-dst) date and get its offset + var nonDSTDate = new Date(new Date().getFullYear(),0,1); + + //given "Tue Apr 08 2014 08:24:50 GMT-0400 (EDT)", get "-0400" + settings.timezoneOffset = nonDSTDate.toString().split(' ')[5].substring(3); + } + _.each(settings.datasources, function(datasource, key) { datasource.name = key; parseBasicAuth(datasource); diff --git a/src/config.sample.js b/src/config.sample.js index 3a2eb9c1108..00d39034550 100644 --- a/src/config.sample.js +++ b/src/config.sample.js @@ -38,6 +38,7 @@ function (Settings) { /** * If your graphite server has another timezone than you & users browsers specify the offset here * Example: "-0500" (for UTC - 5 hours) + * If your graphite server runs UTC, you can set this to "auto" and it will pick the right timezone for you */ timezoneOffset: null,