Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

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  
    2525      # 23 hrs, 59 mins, 29 secs <-> 47 hrs, 59 mins, 29 secs                     # => 1 day 
    2626      # 47 hrs, 59 mins, 29 secs <-> 29 days, 23 hrs, 59 mins, 29 secs            # => [2..29] days 
    2727      # 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] months 
    29       # 1 yr minus 30 secs <-> 2 yrs minus 31 secs                                # => about 1 year 
    30       # 2 yrs minus 30 secs <-> max time or date                                  # => over [2..X] years 
     28      # 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 
    3131      # 
    3232      # With include_seconds = true and the difference < 1 minute 29 seconds 
    3333      # 0-4   secs      # => less than 5 seconds 
     
    4444      #   distance_of_time_in_words(from_time, from_time + 15.seconds) # => less than a minute 
    4545      #   distance_of_time_in_words(from_time, from_time + 15.seconds, true) # => less than 20 seconds 
    4646      # 
    47       # Note: Rails calculates one year as 365.25 days. 
    4847      def distance_of_time_in_words(from_time, to_time = 0, include_seconds = false) 
    4948        from_time = from_time.to_time if from_time.respond_to?(:to_time) 
    5049        to_time = to_time.to_time if to_time.respond_to?(:to_time)