Thanks guys! I have done this:
def remaining_time
if expiration != nil
diff = expiration - Time.now
days = (diff / 1.day).to_i
hours = ((diff / 1.hour) % 24).to_i
mins = ((diff / 1.minute) 60).to_i
if diff < 7.days
return days.to_s + "gg, " + hours.to_s + ":" + mins.to_s
else
return "more than 7 days"
end
end
end
I'll try to improve it! If you have some advices, they are wellcomes..
--
Posted via http://www.ruby-forum.com/.