-
Notifications
You must be signed in to change notification settings - Fork 965
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 precision to DateTime.Humanize #101
Comments
I think it can be better if we defined precision as percentage. Let's say by default precision = 0.75 if someone prefers to override it to be either 0.5 or 0.95 for example, that's fine. 0.75 of a minute => if (delta >= 45 seconds) => about a minute There's another place we can examine for ideas.. Ruby::ActionView::Helpers::DateHelper distance_of_time_in_words |
That's a great idea @waheedsayed. Thanks. By breaking change I didn't mean API breaking change but behavioural. After this change the call that would previously return "a few hours ago" will return "yesterday" and that's a breaking change from my point of view. I think we could implement this and set the default to 1 for now, and as part of V2 we could decrease it a bit. |
Done in #165 |
e.g. (55 days).Humanize(precision:5) => "2 months" (instead of one month)
We also need to apply a sensible default based on each unit; e.g.
Also perhaps these defaults should be lower for singular units; e.g. 25 days shouldn't report as one month; but 29 days perhaps could report as one month while 55 days reports as 2 months! A bit unsure about this as it might get a bit confusing.
Either way this is a breaking change and as such set for V2.
The text was updated successfully, but these errors were encountered: