Totally weird behavior
Closed this issue · 6 comments
dotiw totally gives wrong results when i try to find distance within month (1 - 27 days) otherwise it works fine.
Here's an example.
> distance_of_time_in_words(Date.today, Date.today - 2.days) => '14929920000 days'
Hi! I’m pretty sure the weird result in this case is caused by trying to calculate the distance with a date in the past. Granted, we should probably make sure to take the modulus before we do any calculations anyway.
@lauranjansen Yes i'm calculating the distance with a date in the past.
I might be wrong (it’s been a while), but I think the intended use is to put the past date in the first argument and in your case Date.today in the second one.
@lauranjansen It gives the same result no matter where i put the past date. Is this is a bug in gem or i'm doing something wrong.
Hey @rabnawaz63, do you still have this problem? I don't think the code base has changed, but when I run the same command I get the correct output:
distance_of_time_in_words(Date.today, Date.today - 2.days) => "2 days"
distance_of_time_in_words(Date.today - 2.days, Date.today) => "2 days"
This works as expected now, added tests in dblock@01fc1cb.