Fork me on GitHub
#juxt
<
2019-08-07
>
maxt15:08:39

@doglooksgood I also noticed that I need a locale package to do any formatting, but then I found the Intl.DateTimeFormat browser api that solved it in a for me better way.

(defn intl-format
  "Format dates with the Intl.DateTimeFormat browser API"
  [locale options date]
  (.format (js/Intl.DateTimeFormat. locale (clj->js options))
           (t/inst date)))
(intl-format "sv-SE" {:weekday "long" :year "numeric" :month "short" :day "numeric"} dt)
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat

tianshu15:08:26

@maxt Hi, what is the Intl.DateTimeFormat?

maxt15:08:42

@doglooksgood See updated message (I hit enter to early)

tianshu15:08:55

thanks for the example!

tianshu15:08:22

Why Intl.DateTimeFormat can be used for js-joda?

maxt15:08:03

It's only for inst. I simply convert js-joda times to inst with (t/inst dt) before passing it to Intl.DateTimeFormat.

tianshu15:08:06

@maxt Thanks!

👍 4