Skip to content
Snippets Groups Projects
Unverified Commit 443d4616 authored by Noah Moss's avatar Noah Moss Committed by GitHub
Browse files

fix xlsx month bucketing regression (#24026)

parent 1c091d72
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
......@@ -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)))))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment