-
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
Issue unparsing duration #117
Comments
Looking at this line in Potential fix would be to relax the conversion of periods to millis here to allow for cases with 0 month and years. But this still doesn't fix the general case. Looking at what So, the consistent solution is actually to say that Periods can't be unparsed this way. But probably time to ask lib author @andrewmcveigh ... |
I think probably the best thing to do is to not set cljs-time/src/cljs_time/core.cljs Line 804 in c6c3047
I think I'd say that's a bug. |
Out of curiosity, what benefit does the conversion + |
As far as I remember, none. Other than I didn't have to write the conversion or |
So, what the right behaviour then?
what should
feels like it should either be "1 year", in which case we should skip |
I think your intuition is right, it should be But, it's a bit tricky in that cljs-time's periods are a bit loose (as are {:days 200 :years 1 :months 80} What even is that? Should we care? |
Given that any arbitrary period only makes sense contextually (because of the conversion issue), I don't think the formatter can worry about it. The formatter should probably just worry about generating a string from the period in a naive way. It's probably best to leave it to the caller to understand the contextual nature of a period, and whether the period they are dealing with is in a fully reduced form. This naive formatting function would still have utility and save folks from having to re-implement it. IMO, the place to worry about whether a period is automatically reduced is probably in |
Yep, I think you're right. Was about to say the same. |
Running into an issue with `cljs-time.format/unparse-duration:
Using Clojure 1.9.0-beta4, Clojurescript 1.9.946. Am I doing something wrong?
The text was updated successfully, but these errors were encountered: