Created
January 22, 2009 00:48
-
-
Save dnch/50358 to your computer and use it in GitHub Desktop.
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
def normalise_duration(duration_string) | |
seconds, minutes, hours = duration_string.split(/[:.]/).reverse.map(&:to_i) | |
# the extra to_i handles a nice case where nil.to_i == 0 | |
seconds + (minutes.to_i * 60) + (hours.to_i * 3600) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment