Created
October 14, 2009 16:23
-
-
Save davidrupp/210196 to your computer and use it in GitHub Desktop.
seconds_to_days_hours_minutes_seconds
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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