Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save joshuaclayton/225191 to your computer and use it in GitHub Desktop.

Select an option

Save joshuaclayton/225191 to your computer and use it in GitHub Desktop.
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment