Skip to content

Instantly share code, notes, and snippets.

@davidrupp
Created October 14, 2009 16:23
Show Gist options
  • Save davidrupp/210196 to your computer and use it in GitHub Desktop.
Save davidrupp/210196 to your computer and use it in GitHub Desktop.
seconds_to_days_hours_minutes_seconds
seconds = 356521
days, hours, minutes, seconds =
[1.day, 1.hour, 1.minute, 1.second].inject([]) do |acc, unit|
quotient, seconds = seconds.divmod unit
acc << quotient
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment