Created
June 18, 2013 13:03
-
-
Save natritmeyer/5805166 to your computer and use it in GitHub Desktop.
Converts a float/active_support-time to print a duration (ie: a date time that starts from 0000 instead of the epoch, ie: 1/1/1970)
This file contains hidden or 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
require 'active_support/time' | |
def duration_of(input) | |
Time.at(input).gmtime.strftime "0000-00-00T%H:%M:%S" | |
end | |
duration_of 6.seconds #=> "0000-00-00T00:00:06" | |
duration_of 70.seconds #=> "0000-00-00T00:01:10" | |
duration_of 5.minutes #=> "0000-00-00T00:05:00" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks to @JamsAlx for the inspiration