Ticket #7192: update-date-helper-docs-for-duration-fixes.diff
| File update-date-helper-docs-for-duration-fixes.diff, 1.8 kB (added by eventualbuddha, 2 years ago) |
|---|
-
actionpack/lib/action_view/helpers/date_helper.rb
old new 25 25 # 23 hrs, 59 mins, 29 secs <-> 47 hrs, 59 mins, 29 secs # => 1 day 26 26 # 47 hrs, 59 mins, 29 secs <-> 29 days, 23 hrs, 59 mins, 29 secs # => [2..29] days 27 27 # 29 days, 23 hrs, 59 mins, 30 secs <-> 59 days, 23 hrs, 59 mins, 29 secs # => about 1 month 28 # 59 days, 23 hrs, 59 mins, 30 secs <-> 1 yr minus 31 secs# => [2..12] months29 # 1 yr minus 30 secs <-> 2 yrs minus 31 secs# => about 1 year30 # 2 yrs minus 30 secs <-> max time or date# => over [2..X] years28 # 59 days, 23 hrs, 59 mins, 30 secs <-> 1 yr minus 1 sec # => [2..12] months 29 # 1 yr <-> 2 yrs minus 1 secs # => about 1 year 30 # 2 yrs <-> max time or date # => over [2..X] years 31 31 # 32 32 # With include_seconds = true and the difference < 1 minute 29 seconds 33 33 # 0-4 secs # => less than 5 seconds … … 44 44 # distance_of_time_in_words(from_time, from_time + 15.seconds) # => less than a minute 45 45 # distance_of_time_in_words(from_time, from_time + 15.seconds, true) # => less than 20 seconds 46 46 # 47 # Note: Rails calculates one year as 365.25 days.48 47 def distance_of_time_in_words(from_time, to_time = 0, include_seconds = false) 49 48 from_time = from_time.to_time if from_time.respond_to?(:to_time) 50 49 to_time = to_time.to_time if to_time.respond_to?(:to_time)