mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
distance_of_time_in_words: 45-60 days is about 2 months, not about 1 month
This commit is contained in:
parent
c435feb404
commit
d2f995eda9
2 changed files with 6 additions and 3 deletions
|
@ -29,7 +29,8 @@ module ActionView
|
|||
# 89 mins, 30 secs <-> 23 hrs, 59 mins, 29 secs # => about [2..24] hours
|
||||
# 23 hrs, 59 mins, 30 secs <-> 41 hrs, 59 mins, 29 secs # => 1 day
|
||||
# 41 hrs, 59 mins, 30 secs <-> 29 days, 23 hrs, 59 mins, 29 secs # => [2..29] days
|
||||
# 29 days, 23 hrs, 59 mins, 30 secs <-> 59 days, 23 hrs, 59 mins, 29 secs # => about 1 month
|
||||
# 29 days, 23 hrs, 59 mins, 30 secs <-> 44 days, 23 hrs, 59 mins, 29 secs # => about 1 month
|
||||
# 44 days, 23 hrs, 59 mins, 30 secs <-> 59 days, 23 hrs, 59 mins, 29 secs # => about 2 months
|
||||
# 59 days, 23 hrs, 59 mins, 30 secs <-> 1 yr minus 1 sec # => [2..12] months
|
||||
# 1 yr <-> 1 yr, 3 months # => about 1 year
|
||||
# 1 yr, 3 months <-> 1 yr, 9 months # => over 1 year
|
||||
|
@ -100,7 +101,7 @@ module ActionView
|
|||
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 => 1
|
||||
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
|
||||
else
|
||||
if from_time.acts_like?(:time) && to_time.acts_like?(:time)
|
||||
|
|
|
@ -77,7 +77,9 @@ class DateHelperTest < ActionView::TestCase
|
|||
|
||||
# 43200..86399
|
||||
assert_equal "about 1 month", distance_of_time_in_words(from, to + 29.days + 23.hours + 59.minutes + 30.seconds)
|
||||
assert_equal "about 1 month", distance_of_time_in_words(from, to + 59.days + 23.hours + 59.minutes + 29.seconds)
|
||||
assert_equal "about 1 month", distance_of_time_in_words(from, to + 44.days + 23.hours + 59.minutes + 29.seconds)
|
||||
assert_equal "about 2 months", distance_of_time_in_words(from, to + 44.days + 23.hours + 59.minutes + 30.seconds)
|
||||
assert_equal "about 2 months", distance_of_time_in_words(from, to + 59.days + 23.hours + 59.minutes + 29.seconds)
|
||||
|
||||
# 86400..525599
|
||||
assert_equal "2 months", distance_of_time_in_words(from, to + 59.days + 23.hours + 59.minutes + 30.seconds)
|
||||
|
|
Loading…
Reference in a new issue