Revisions

gist: 225191 Download_button fork
public
Public Clone URL: git://gist.github.com/225191.git
Embed All Files: show embed
day hour minute format based on seconds passed.rb #
1
2
3
4
5
6
7
8
9
def time_distance(seconds = 0)
  days, hours, minutes = 0,0,0
  in_days = seconds / (60*60*24)
 
  days = in_days.floor
  hours = ((in_days % days) * 24).floor
  minutes = ((((in_days % days) * 24) % hours) * 60).floor
  "#{days}d #{hours}h #{minutes}m"
end