Class: Duration
- Inherits:
-
Object
- Object
- Duration
- Defined in:
- lib/duration.rb
Class Method Summary collapse
Class Method Details
.format_time(milliseconds) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/duration.rb', line 2 def self.format_time(milliseconds) return "0:00" if milliseconds <= 0 hours = milliseconds.to_i / 3600000 minutes = milliseconds.to_i / 60000 % 60 seconds = milliseconds/1000.0 % 60 if hours > 0 "%i:%02i:%02i" % [ hours, minutes, seconds ] else "%i:%02i" % [ minutes, seconds ] end end |