lib/active_support/duration.rb in activesupport-2.3.2 vs lib/active_support/duration.rb in activesupport-2.3.3

- old
+ new

@@ -65,13 +65,15 @@ end alias :until :ago def inspect #:nodoc: consolidated = parts.inject(::Hash.new(0)) { |h,part| h[part.first] += part.last; h } - [:years, :months, :days, :minutes, :seconds].map do |length| + parts = [:years, :months, :days, :minutes, :seconds].map do |length| n = consolidated[length] "#{n} #{n == 1 ? length.to_s.singularize : length.to_s}" if n.nonzero? - end.compact.to_sentence(:locale => :en) + end.compact + parts = ["0 seconds"] if parts.empty? + parts.to_sentence(:locale => :en) end protected def sum(sign, time = ::Time.current) #:nodoc: