This project is archived and is in readonly mode.
[PATCH] distance_of_time_in_words inaccurate for 'about 1 year ago'
Reported by Ben Fyvie | August 27th, 2009 @ 05:35 PM
When I think of a date that is "about 1 year ago" I think a year and a month ago or possibly a year and two months ago. However the math used in distance_of_time_in_words accounts for everything up to 1 minute short of two years as being "about a year ago" that means that 1 year 364 days 23 hours and 59 minutes is "about 1 year ago".
I feel dates up to 1 year and one month would better fit the category of "about 1 year ago" anything above that should fall into the "Over 1 year ago" category
Comments and changes to this ticket
-
John Pignata September 4th, 2009 @ 05:50 PM
I agree with this feature request in spirit as small and worthwhile, but it certainly requires discussion.
This patch enhances distance_of_time_in_words to prefix the year string with either "about" or "over" depending upon how many months have elapsed in that year. The logic here is that if the half year mark has been passed, the time string should be "over x years" while in the case where that mark has not been passed the "about x years" syntax should be used.
Examples:
distance_of_time_in_words(from_time, from_time + 1.year + 3.days) # => about 1 year distance_of_time_in_words(from_time, from_time + 3.years + 6.months) # => over 3 years distance_of_time_in_words(from_time, from_time + 4.years + 9.days + 30.minutes + 5.seconds) # => about 4 years distance_of_time_in_words(from_time, from_time + 10.years + 2.days) # => about 10 years
-
John Pignata September 18th, 2009 @ 04:14 AM
- Tag changed from action_view, date_helper to action_view, date_helper, patch
- Title changed from distance_of_time_in_words inaccurate for 'about 1 year ago' to [PATCH] distance_of_time_in_words inaccurate for 'about 1 year ago'
-
John Pignata September 26th, 2009 @ 03:36 PM
- Tag changed from action_view, date_helper, patch to action_view, bugmash, date_helper, patch
Putting a bugmash tag on this to try to get this discussed. I know it's minor, but it's a bugaboo of mine that after an object exceeds a year in age, time_ago_in_words becomes obtuse.
-
John Trupiano September 26th, 2009 @ 04:55 PM
I'd be in favor of introducing the "almost" identifier as well. For instance, I'd think that distance_of_time_in_words(from_time, from_time + 3.years + 10.months) should return "almost 4 years" or "less than 4 years."
-
Lena Herrmann September 26th, 2009 @ 05:09 PM
That's a +1 from me, I like it and it works as expected on 3.2.
-
sr.iniv.t September 26th, 2009 @ 05:37 PM
+1 from me too. 1.year + 11.months is certainly not "about 1 year ago". It makes sense to 'about' and 'over' prefixes.
Patch applies on 2-3-stable and works as expected.
-
Dan Pickett September 26th, 2009 @ 05:38 PM
John Trupiano,
I think you should create another ticket for the introduction of the "almost" identifier. I think that's more accurate than "over" given a certain threshold (say after 10 months).
-
John Trupiano September 26th, 2009 @ 05:41 PM
Dan, I was thinking at 9 months. In the general case, I was thinking that once it's past 3/4 the distance between the 2 whole values that we should switch to "almost the greater value."
Anyone else have thoughts? I'll start whipping up the patch.
-
John Trupiano September 26th, 2009 @ 05:52 PM
Looking at this other example:
distance_of_time_in_words(from_time, from_time + 50.minutes) # => about 1 hour
I'd think we'd just keep with 'about' instead of 'almost', e.g.
distance_of_time_in_words(from_time, from_time + 3.years + 9.months) # => about 4 years
-
Dan Pickett September 26th, 2009 @ 05:56 PM
- Tag changed from action_view, bugmash, date_helper, patch to action_view, bugmash, bugmash-review, date_helper, patch
-
John Trupiano September 26th, 2009 @ 09:16 PM
fyi, I created a separate ticket that builds on this patch as Dan Pickett suggested: https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets...
-
Blue Box Jesse September 26th, 2009 @ 09:16 PM
Bug Mash +1
I think this is a valuable patch, but I also think that the wording of "over 3 years" isn't quite clear. To me, over 3 years seems to imply that the date could be 4, 5 or 6 years.
Logically, to me, I would think it would work like this:
1 year 0-6 months should be "about 1 year"
1 year 7-12 mo should be "almost 2 years" -
CancelProfileIsBroken September 27th, 2009 @ 12:35 PM
- Tag changed from action_view, bugmash, bugmash-review, date_helper, patch to action_view, bugmash-review, date_helper, patch
-
Matías Flores September 27th, 2009 @ 05:25 PM
- Tag changed from action_view, bugmash-review, date_helper, patch to action_view, bugmash-review, date_helper, patch
+1 verified John's patch applies cleanly in both master and 2-3-stable and all tests pass.
-
Repository September 28th, 2009 @ 03:29 AM
- State changed from new to committed
(from [b372b4c87515ab84e64028b437da1e047a128e4d]) Enhancing distance_of_time_in_words to prefix year output with over and about depending upon how many months have elapsed
Signed-off-by: Michael Koziarski michael@koziarski.com
[#3106 state:committed] http://github.com/rails/rails/commit/b372b4c87515ab84e64028b437da1e... -
Repository September 28th, 2009 @ 03:29 AM
(from [8ef1cd9733cd12fc4e5ea25c149956a33fdffa70]) Enhancing distance_of_time_in_words to prefix year output with over and about depending upon how many months have elapsed
Signed-off-by: Michael Koziarski michael@koziarski.com
[#3106 state:committed] http://github.com/rails/rails/commit/8ef1cd9733cd12fc4e5ea25c149956... -
Rizwan Reza May 15th, 2010 @ 06:42 PM
- Tag changed from action_view, bugmash-review, date_helper, patch to action_view, date_helper, patch
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>
People watching this ticket
Attachments
Tags
Referenced by
- 3266 [PATCH] distance_of_time_in_words misleading for durations close to full years or close to 48 hours This patch builds on top of #3106 ( https://rails.lighth...
- 3266 [PATCH] distance_of_time_in_words misleading for durations close to full years or close to 48 hours +1 verified patch applies cleanly in both master and 2-3-...
- 3266 [PATCH] distance_of_time_in_words misleading for durations close to full years or close to 48 hours +1 for this in combination with patch in #3106. The attac...
- 3106 [PATCH] distance_of_time_in_words inaccurate for 'about 1 year ago' Signed-off-by: Michael Koziarski michael@koziarski.com [#...
- 3106 [PATCH] distance_of_time_in_words inaccurate for 'about 1 year ago' Signed-off-by: Michael Koziarski michael@koziarski.com [#...