diff options
author | Elliot Winkler <elliot.winkler@gmail.com> | 2012-02-25 16:23:31 -0700 |
---|---|---|
committer | Elliot Winkler <elliot.winkler@gmail.com> | 2012-04-30 11:29:36 -0600 |
commit | 297359bcfd4164ea88497669717a7f3c65c1d4f9 (patch) | |
tree | 50bfe518cbf2550b58d59d4575be00a662efd8b8 /actionpack/lib/action_view | |
parent | d2f995eda9df2cc714fe1552604903008ed0baaf (diff) | |
download | rails-297359bcfd4164ea88497669717a7f3c65c1d4f9.tar.gz rails-297359bcfd4164ea88497669717a7f3c65c1d4f9.tar.bz2 rails-297359bcfd4164ea88497669717a7f3c65c1d4f9.zip |
distance_of_time_in_words: Add/tweak comments to understand time intervals better
Diffstat (limited to 'actionpack/lib/action_view')
-rw-r--r-- | actionpack/lib/action_view/helpers/date_helper.rb | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/actionpack/lib/action_view/helpers/date_helper.rb b/actionpack/lib/action_view/helpers/date_helper.rb index 79b9ae60a6..6bd8e62e0d 100644 --- a/actionpack/lib/action_view/helpers/date_helper.rb +++ b/actionpack/lib/action_view/helpers/date_helper.rb @@ -96,13 +96,18 @@ module ActionView else locale.t :x_minutes, :count => 1 end - when 2..44 then locale.t :x_minutes, :count => distance_in_minutes - when 45..89 then locale.t :about_x_hours, :count => 1 - when 90..1439 then locale.t :about_x_hours, :count => (distance_in_minutes.to_f / 60.0).round - when 1440..2519 then locale.t :x_days, :count => 1 - when 2520..43199 then locale.t :x_days, :count => (distance_in_minutes.to_f / 1440.0).round - when 43200..86399 then locale.t :about_x_months, :count => (distance_in_minutes.to_f / 43200.0).round - when 86400..525599 then locale.t :x_months, :count => (distance_in_minutes.to_f / 43200.0).round + when 2...45 then locale.t :x_minutes, :count => distance_in_minutes + when 45...90 then locale.t :about_x_hours, :count => 1 + # 90 mins up to 24 hours + when 90...1440 then locale.t :about_x_hours, :count => (distance_in_minutes.to_f / 60.0).round + # 24 hours up to 42 hours + when 1440...2520 then locale.t :x_days, :count => 1 + # 42 hours up to 30 days + when 2520...43200 then locale.t :x_days, :count => (distance_in_minutes.to_f / 1440.0).round + # 30 days up to 60 days + when 43200...86400 then locale.t :about_x_months, :count => (distance_in_minutes.to_f / 43200.0).round + # 60 days up to 365 days + when 86400...525600 then locale.t :x_months, :count => (distance_in_minutes.to_f / 43200.0).round else if from_time.acts_like?(:time) && to_time.acts_like?(:time) fyear = from_time.year |