diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2006-08-05 21:34:18 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2006-08-05 21:34:18 +0000 |
commit | 8eaf479156a413b8c6e98649b6326c7baa010b43 (patch) | |
tree | f0fe766d0bdb94ffd1c6bdc3ddf98c0ac094b7ca /actionpack/lib/action_view/helpers | |
parent | 21cf3c6596de877dd12dcedb5637a1a8bf90b327 (diff) | |
download | rails-8eaf479156a413b8c6e98649b6326c7baa010b43.tar.gz rails-8eaf479156a413b8c6e98649b6326c7baa010b43.tar.bz2 rails-8eaf479156a413b8c6e98649b6326c7baa010b43.zip |
Added months and years to the resolution of DateHelper#distance_of_time_in_words, such that "60 days ago" becomes "2 months ago" (closes #5611) [pjhyett@gmail.com]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4674 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_view/helpers')
-rwxr-xr-x | actionpack/lib/action_view/helpers/date_helper.rb | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/actionpack/lib/action_view/helpers/date_helper.rb b/actionpack/lib/action_view/helpers/date_helper.rb index 4920763b50..7c65b0db39 100755 --- a/actionpack/lib/action_view/helpers/date_helper.rb +++ b/actionpack/lib/action_view/helpers/date_helper.rb @@ -39,11 +39,15 @@ module ActionView else '1 minute' end - when 2..45 then "#{distance_in_minutes} minutes" - when 46..90 then 'about 1 hour' - when 90..1440 then "about #{(distance_in_minutes.to_f / 60.0).round} hours" - when 1441..2880 then '1 day' - else "#{(distance_in_minutes / 1440).round} days" + when 2..45 then "#{distance_in_minutes} minutes" + when 46..90 then 'about 1 hour' + when 90..1440 then "about #{(distance_in_minutes.to_f / 60.0).round} hours" + when 1441..2880 then '1 day' + when 2881..43220 then "#{(distance_in_minutes / 1440).round} days" + when 43201..86400 then 'about 1 month' + when 86401..525960 then "#{(distance_in_minutes / 43200).round} months" + when 525961..1051920 then 'about 1 year' + else "over #{(distance_in_minutes / 525600).round} years" end end |