Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

Fix wrong timezone in "exclude hours" filters (#64290)

Marcos471b6f57e55e
diff --git a/src/metabase/driver/common/parameters/dates.clj b/src/metabase/driver/common/parameters/dates.clj
index 3228f0d28ab..d9b64c76efe 100644
--- a/src/metabase/driver/common/parameters/dates.clj
+++ b/src/metabase/driver/common/parameters/dates.clj
@@ -298,7 +298,7 @@
(let [year (t/year date)]
(case unit
:hour (when-let [hour (parse-int-in-range exclusion 0 23)]
- (format "%sT%02d:00:00Z" date hour))
+ (format "%sT%02d:00:00" date hour))
:day (when-let [day (short-day->day exclusion)]
(str (t/adjust date :next-or-same-day-of-week day)))
:month (when-let [month (short-month->month exclusion)]
diff --git a/src/metabase/query_processor/parameters/dates.clj b/src/metabase/query_processor/parameters/dates.clj
index 1f50bf3f22e..829abcdf843 100644
--- a/src/metabase/query_processor/parameters/dates.clj
+++ b/src/metabase/query_processor/parameters/dates.clj
@@ -303,7 +303,7 @@
(let [year (t/year date)]
(case unit
:hour (when-let [hour (parse-int-in-range exclusion 0 23)]
- (format "%sT%02d:00:00Z" date hour))
+ (format "%sT%02d:00:00" date hour))
:day (when-let [day (short-day->day exclusion)]
(str (t/adjust date :next-or-same-day-of-week day)))
:month (when-let [month (short-month->month exclusion)]
diff --git a/test/metabase/driver/common/parameters/dates_test.clj b/test/metabase/driver/common/parameters/dates_test.clj
index 934741d78dc..9cf006b9999 100644
--- a/test/metabase/driver/common/parameters/dates_test.clj
+++ b/test/metabase/driver/common/parameters/dates_test.clj
@@ -97,12 +97,12 @@
(testing "hours"
(is (= [:!=
[:field "field" {:base-type :type/DateTime, :temporal-unit :hour-of-day}]
- "2016-06-07T00:00:00Z"]
+ "2016-06-07T00:00:00"]
(params.dates/date-string->filter "exclude-hours-0" [:field "field" {:base-type :type/DateTime}])))
(is (= [:!=
[:field "field" {:base-type :type/DateTime, :temporal-unit :hour-of-day}]
- "2016-06-07T00:00:00Z"
- "2016-06-07T23:00:00Z"]
+ "2016-06-07T00:00:00"
+ "2016-06-07T23:00:00"]
(params.dates/date-string->filter "exclude-hours-0-23" [:field "field" {:base-type :type/DateTime}])))
(is (thrown? clojure.lang.ExceptionInfo #"Don't know how to parse date string \"exclude-hours-\""
(params.dates/date-string->filter "exclude-hours-" [:field "field" {:base-type :type/DateTime}])))
diff --git a/test/metabase/query_processor/parameters/dates_test.clj b/test/metabase/query_processor/parameters/dates_test.clj
index 741d26b35af..e755de2a5d6 100644
--- a/test/metabase/query_processor/parameters/dates_test.clj
+++ b/test/metabase/query_processor/parameters/dates_test.clj
@@ -196,15 +196,15 @@
(is (=? [:!=
{}
[:field {:base-type :type/DateTime, :temporal-unit :hour-of-day} "field"]
- "2016-06-07T00:00:00Z"]
+ "2016-06-07T00:00:00"]
(params.dates/date-string->filter
"exclude-hours-0"
[:field {:lib/uuid "00000000-0000-0000-0000-000000000000", :base-type :type/DateTime} "field"])))
(is (=? [:!=
{}
[:field {:base-type :type/DateTime, :temporal-unit :hour-of-day} "field"]
- "2016-06-07T00:00:00Z"
- "2016-06-07T23:00:00Z"]
+ "2016-06-07T00:00:00"
+ "2016-06-07T23:00:00"]
(params.dates/date-string->filter
"exclude-hours-0-23"
[:field {:lib/uuid "00000000-0000-0000-0000-000000000000", :base-type :type/DateTime} "field"])))