Skip to content
Snippets Groups Projects
Unverified Commit 8fa8b18f authored by adam-james's avatar adam-james Committed by GitHub
Browse files

Add processing step to the date format string so that we get Day of Month (#27557)

Since the frontend sends a date-style string with various differences from how Java's Date Formatter expects things,
we need to post-process some bits. The 'D' -> 'd' string replacement was missed in the post processing fn, and so in
some cases it was missed altogether, causing this bug.

Existing tests in `metabase.pulse.render.datetime-test` and `metabase.pulse.render.table-test` should already catch
this issue. Prior to the change they would fail, but they now pass after adding this PR's changes.
parent 974e57a9
No related branches found
No related tags found
No related merge requests found
......@@ -84,11 +84,15 @@
(-> (:type/Temporal (public-settings/custom-formatting))
(update-keys (fn [k] (-> k name (str/replace #"_" "-") keyword)))))
post-process-date-style (fn [date-style]
(cond-> (-> date-style (str/replace #"dddd" "EEEE"))
date-separator (str/replace #"/" date-separator)
abbreviate (-> (str/replace #"MMMM" "MMM")
(str/replace #"EEEE" "EEE")
(str/replace #"DDD" "D"))))]
(let [conditional-changes
(cond-> (-> date-style (str/replace #"dddd" "EEEE"))
date-separator (str/replace #"/" date-separator)
abbreviate (-> (str/replace #"MMMM" "MMM")
(str/replace #"EEEE" "EEE")
(str/replace #"DDD" "D")))]
(-> conditional-changes
;; 'D' formats as Day of Year, we want Day of Month, which is 'd' (issue #27469)
(str/replace #"D" "d"))))]
(case (:unit col)
;; these types have special formatting
:minute (reformat-temporal-str timezone-id s
......@@ -119,5 +123,4 @@
;; for everything else return in this format
(reformat-temporal-str timezone-id s (-> (or date-style "MMMM d, yyyy")
(str/replace #"D" "d")
post-process-date-style)))))))
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