lib/sup/util.rb in sup-0.0.4 vs lib/sup/util.rb in sup-0.0.5
- old
+ new
@@ -222,19 +222,19 @@
text =
[ ["second", 60],
["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
+ if diff.round <= 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
if later_than
text + " ago"