-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add locale support for unparse using a formatter #77
Conversation
|
||
LocalizedFormatter | ||
(unparse [{:keys [format-str formatters date-time-symbols] :as fmt} dt] | ||
(with-redefs [i/months (.-MONTHS date-time-symbols) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a way you can think of to do this without using re-binding vars?
I'm not keen on adding code containing with-redefs
to library code.
@@ -233,7 +255,7 @@ | |||
:let [d (try (parse-local-date f s) (catch js/Error _ nil))] | |||
:when d] d)))) | |||
|
|||
(defn unparse | |||
(defn do-unparse |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer to keep this function as part of the API, and perhaps defer to the protocol implementation for say -unparse
. That's how clojurescript core does this kind of thing... it's a bit more flexible that way.
lfmt-month (with-locale fmt-month goog.i18n.DateTimeSymbols_fr)] | ||
(is (= "quinta-feira, 11 de março de 2010" (unparse lfmt (local-date 2010 3 11)))) | ||
(is (= "lundi 11 février 2013" (unparse lfmt-month (local-date 2013 2 11)))))) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests! Awesome :)
Hey, Thanks very much for this. I've a couple comments above. Mainly about the use of |
See #85 for a fuller implementation. |
I developed support for localized formatter using the with-locale function.