Skip to content

Commit

Permalink
Keep time zone information when creating widget
Browse files Browse the repository at this point in the history
Absolute time ranges in widgets were getting converted into
ES_DATE_FORMAT, which converts the time into UTC, but loses the time
zone information from the string representation. As the AbsoluteRange
create method parses the date time and tries to keep the time zone
information, that resulted in UTC times being converted into local time.

To fix the problem we avoid using ES_DATE_FORMAT, and use ISO8601
instead.

Fixes #2428
  • Loading branch information
Edmundo Alvarez committed Jul 4, 2016
1 parent 2ed9d94 commit 5d6d8ff
Showing 1 changed file with 2 additions and 3 deletions.
Expand Up @@ -17,7 +17,6 @@
package org.graylog2.timeranges;

import com.google.common.base.Strings;
import org.graylog2.plugin.Tools;
import org.graylog2.plugin.indexer.searches.timeranges.AbsoluteRange;
import org.graylog2.plugin.indexer.searches.timeranges.InvalidRangeParametersException;
import org.graylog2.plugin.indexer.searches.timeranges.KeywordRange;
Expand All @@ -40,8 +39,8 @@ public TimeRange create(final Map<String, Object> timerangeConfig) throws Invali
case "keyword":
return KeywordRange.create((String) timerangeConfig.get("keyword"));
case "absolute":
final String from = new DateTime(timerangeConfig.get("from"), DateTimeZone.UTC).toString(Tools.ES_DATE_FORMAT);
final String to = new DateTime(timerangeConfig.get("to"), DateTimeZone.UTC).toString(Tools.ES_DATE_FORMAT);
final String from = new DateTime(timerangeConfig.get("from"), DateTimeZone.UTC).toString();
final String to = new DateTime(timerangeConfig.get("to"), DateTimeZone.UTC).toString();

return AbsoluteRange.create(from, to);
default:
Expand Down

0 comments on commit 5d6d8ff

Please sign in to comment.