Using the Subunit gem to fracture seconds to hours, minutes, and seconds

require 'subunit'
Subunit.new(units={minutes:60, hours:60}, seconds: 1802).to_h
#=> {:hours=>0, :minutes=>30, :seconds=>2}

a[0..-2].map {|x|"%d %s" % x.reverse}.join + ", and %d %s" % a[-1].reverse

#=> "30 minutes, and 2 seconds" 


Resources

Tags:
Source:
2151hrs.txt
Published:
05-02-2013 21:51