Ruby Function Time Diff To String
diff = time1 - time2
if diff < 1.minute
return diff.ceil.to_s + " seconds"
elsif diff < 1.hour
return (diff / 1.minute).ceil.to_s + " minutes"
elsif diff < 1.day
return (diff / 1.hour).ceil.to_s + " hours"
elsif diff < 7.day
return (diff / 1.day).ceil.to_s + " days"
elsif diff < 1.month
return (diff / 1.week).ceil.to_s + " weeks"
elsif diff < 1.year
return (diff / 1.month).ceil.to_s + " months"
else
return (diff / 1.year).ceil.to_s + " years"
end
end