diff --git a/src/metabase/query_processor/streaming/xlsx.clj b/src/metabase/query_processor/streaming/xlsx.clj index c386f56ffa565939520775bfb3da0f85e5921350..94637b5748e9f041d30695d54e72bc14fbe37fd4 100644 --- a/src/metabase/query_processor/streaming/xlsx.clj +++ b/src/metabase/query_processor/streaming/xlsx.clj @@ -198,17 +198,20 @@ format-string) format-string)) -(def ^:private month-style-overrides - "Overrides for the date-style in a column's viz settings if :unit is :month." - {"m/d/yyyy" "m/yyyy" - "yyyy/m/d" "yyyy/m" - "mmmm d, yyyy" "mmmm, yyyy"}) +(defn- month-style + "For a given date format, returns the format to use in exports if :unit is :month" + [date-format] + (case date-format + "m/d/yyyy" "m/yyyy" + "yyyy/m/d" "yyyy/m" + ;; Default for all other styles + "mmmm, yyyy")) (defn- date-format [format-settings unit] (let [base-style (str/lower-case (::mb.viz/date-style format-settings "mmmm d, yyyy")) unit-style (case unit - :month (get month-style-overrides base-style) + :month (month-style base-style) :year "yyyy" base-style)] (->> unit-style diff --git a/test/metabase/query_processor/streaming/xlsx_test.clj b/test/metabase/query_processor/streaming/xlsx_test.clj index 650dfad46f8a4f2ec82da89d8eff261f8da1f760..eb4214c86c726e908d626bdf44efef74f53a09b6 100644 --- a/test/metabase/query_processor/streaming/xlsx_test.clj +++ b/test/metabase/query_processor/streaming/xlsx_test.clj @@ -216,6 +216,9 @@ (is (= "mmmm, yyyy" (format-string {} month-col))) (is (= "m/yyyy" (format-string {::mb.viz/date-style "M/D/YYYY"} month-col))) (is (= "yyyy/m" (format-string {::mb.viz/date-style "YYYY/M/D"} month-col))) + (is (= "mmmm, yyyy" (format-string {::mb.viz/date-style "MMMM D, YYYY"} month-col))) + (is (= "mmmm, yyyy" (format-string {::mb.viz/date-style "D MMMM, YYYY"} month-col))) + (is (= "mmmm, yyyy" (format-string {::mb.viz/date-style "DDDD, MMMM D, YYYY"} month-col))) (is (= "yyyy" (format-string {} year-col))) (is (= "yyyy" (format-string {::mb.viz/date-style "M/D/YYYY"} year-col)))))