From: wmorgan Date: Fri, 5 Jan 2007 16:46:13 +0000 (+0000) Subject: improved accuracy of to_nice_distance_of X-Git-Url: https://git.cworth.org/git?a=commitdiff_plain;h=a3d7fa37e575a92217eefb154ae02d53c95f812f;p=sup improved accuracy of to_nice_distance_of git-svn-id: svn://rubyforge.org/var/svn/sup/trunk@183 5c8cc53c-5e98-4d25-b20a-d8db53a31250 --- diff --git a/lib/sup/util.rb b/lib/sup/util.rb index ef2fdb1..0216c51 100644 --- a/lib/sup/util.rb +++ b/lib/sup/util.rb @@ -224,16 +224,16 @@ class Time ["minute", 60], ["hour", 24], ["day", 7], - ["week", 4], # heh heh + ["week", 4.345], # heh heh ["month", 12], ["year", nil], ].argfind do |unit, size| if diff <= 1 "one #{unit}" - elsif size.nil? || diff < size - "#{diff} #{unit}s" + elsif size.nil? || diff.round < size + "#{diff.round} #{unit}s" else - diff = (diff / size.to_f).round + diff /= size.to_f false end end