解决方法
这个怎么样?
a=[1,1000,60000,3600000]*2 ms="01:45:36.180".split(/[:\.]/).map{|time| time.to_i*a.pop}.inject(&:+) # => 6336180 t = "%02d" % (ms / a[3]).to_s << ":" << "%02d" % (ms % a[3] / a[2]).to_s << ":" << "%02d" % (ms % a[2] / a[1]).to_s << "." << "%03d" % (ms % a[1]).to_s # => "01:45:36.180"