Module: Soundcloud9000::TimeHelper
- Defined in:
- lib/soundcloud9000/time_helper.rb
Overview
handles proper time display TODO: make this better looking or find an alternative
Constant Summary collapse
- HOUR =
1000 * 60 * 60
- MINUTE =
1000 * 60
- SECONDS =
1000
Class Method Summary collapse
Class Method Details
.duration(milliseconds) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/soundcloud9000/time_helper.rb', line 11 def self.duration(milliseconds) parts = [ milliseconds / 1000 / 60 / 60, # hours milliseconds / 1000 / 60 % 60, # minutes milliseconds / 1000 % 60 # seconds ] parts.shift if parts.first.zero? [parts.first, *parts[1..-1].map { |part| format('%02d', part) }].join('.') end |