This project is archived and is in readonly mode.
[PATCH] distance_of_time_in_words misleading for durations close to full years or close to 48 hours
Reported by John Trupiano | September 26th, 2009 @ 09:03 PM
This patch builds on top of #3106 ( https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets... ). Please apply that patch first if it has not already been merged into 2-3-stable.
It includes two parts:
Introduce :almost keyword for describing durations that are "almost a year long"
The new rules apply to durations greater than a year. Essentially we use "about" to describe durations that are 0-3 months greater than a whole year, "over" to describe durations that are 3-9 months greater than a whole year, and "almost" to describe durations 9-12 months greater than a whole year.
- distance_of_time_in_words(now, now + 1.years + 9.months)
- before: "over 1 year"
- after: "almost 2 years"
- distance_of_time_in_words(now, now + 2.years)
- before: "about 2 years"
- after: "about 2 years"
- distance_of_time_in_words(now, now + 2.years + 3.months)
- before: "about 2 years"
- after: "over 2 years"
- distance_of_time_in_words(now, now + 2.years + 9.months)
- before: "over 2 years"
- after: "almost 3 years"
Change how 1 day and 2 days are handled
- distance_of_time_in_words(now, now + 47.hours)
- before: "1 day"
- after: "2 days"
For this one I used the same 3/4 ratio that is used for minutes to hours. At 45 minutes the text becomes "1 hour." At 1 day, 18 hours, the text becomes "2 days."
I also cleaned out a few unnecessary calls to #round. #round is only useful for floats, but there were a couple instances of it being called on ints.
Lastly, I updated the rdoc which had become stale.
Comments and changes to this ticket
-
Matías Flores September 27th, 2009 @ 06:44 PM
+1 verified patch applies cleanly in both master and 2-3-stable over patch in #3106
-
Gaius Centus Novus September 27th, 2009 @ 11:00 PM
+1 for this in combination with patch in #3106. The attached patch is a combination of the two.
-
CancelProfileIsBroken September 28th, 2009 @ 01:32 AM
- Tag changed from action_view, bugmash, date_helper, patch to action_view, bugmash-review, date_helper, patch
-
Repository September 28th, 2009 @ 03:29 AM
- State changed from new to committed
(from [c9318e9010712aeae33b1dd0e8bed4795ae37caf]) Introduce :almost keyword for distance_of_time_in_words. Make 1.75 days - 2 days return '2 days'.
Signed-off-by: Michael Koziarski michael@koziarski.com
[#3266 state:committed] http://github.com/rails/rails/commit/c9318e9010712aeae33b1dd0e8bed4... -
Repository September 28th, 2009 @ 03:29 AM
(from [f489b3341c6f5488eadeea0544ce0decc22e351e]) Introduce :almost keyword for distance_of_time_in_words. Make 1.75 days - 2 days return '2 days'.
Signed-off-by: Michael Koziarski michael@koziarski.com
[#3266 state:committed] http://github.com/rails/rails/commit/f489b3341c6f5488eadeea0544ce0d... -
Rizwan Reza May 15th, 2010 @ 06:37 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 Signed-off-by: Michael Koziarski michael@koziarski.com [#...
- 3266 [PATCH] distance_of_time_in_words misleading for durations close to full years or close to 48 hours Signed-off-by: Michael Koziarski michael@koziarski.com [#...