Skip to content
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

Is not grouping the omitted time quantities #120

Open
reymillenium opened this issue Dec 28, 2020 · 1 comment
Open

Is not grouping the omitted time quantities #120

reymillenium opened this issue Dec 28, 2020 · 1 comment

Comments

@reymillenium
Copy link

reymillenium commented Dec 28, 2020

If I call for example:

date1 = "2019-01-02".to_time
date2 = "2020-12-28".to_time
distance_of_time_in_words(date1, date2, false, only: %i[years months days])

The helper method of your gem it's showing me this:
1 year, 11 months, and 5 days

But the thing is that the amount of days is wrong. The amount of real time is:
1 year, 11 months, 3 weeks and 5 days

So your method should say instead:
"1 year, 11 months, and 26 days"

Your method should convert the amount of ignored weeks (because the user simply doesn't want to see the word "weeks" in the returned string") into days (the user wants to see the word "days") and then add all of them (3 weeks x 7 days/week = 21 days) with the rest of the days (5 days), to return a total of 26 days. That's a simple matter of logic.

The fact that I only need the years, months and days, that doesn't mean that I ALSO want a wrong amount of days. I don't want that. I have never decided that. I want to see reflected the difference of time in years, months and days. That's all. But not removing real time and not returning a wrong amount of time.

@dblock
Copy link
Collaborator

dblock commented Dec 29, 2020

I think this is a dup of #77

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants