Class TmDisplay
In: util/tmdisplay.rb
Parent: Object

Format a time (duration) in seconds

Note: values are limited in range:

Note: years and days are based starting Jan. 1, 1970

Methods
format    hms    ms    new   
Attributes
:d  [R] 
:h  [R] 
:m  [R] 
:s  [R] 
:secs  [R] 
:t  [R] 
:y  [R] 
Public Class methods
new(secs)

Create UTC time and extract individual values.

# File util/tmdisplay.rb, line 54
  def initialize(secs)
    @secs = secs
    @t = Time.at(secs)
    @t.utc
    vals = @t.strftime("%Y:%j:%H:%M:%S").split(":")
    @y = (vals.shift.to_i - 1970).to_s
    @d = sprintf("%03d", (vals.shift.to_i - 1))
    @h = vals.shift
    @m = vals.shift
    @s = vals.shift
  end
Public Instance methods
ms()

Return time as MM:SS, truncating hours, days, and years.

# File util/tmdisplay.rb, line 69
  def ms()
    "#{@m}:#{@s}"
  end
hms()

Return time as HH:MM:SS, truncating days and years.

# File util/tmdisplay.rb, line 73
  def hms()
    "#{@h}:#{@m}:#{@s}"
  end
format(fmt)

Format time according to format string fmt.

fmt
Format string using %y, %d, %h, %m, %s, and %% to represent years, days, hours, minutes, seconds, and literal '%' character;
# File util/tmdisplay.rb, line 81
  def format(fmt)
    s = fmt.gsub(/%[Yy]/, @y).gsub(/%[Dd]/, @d)
    s.gsub(/%[Hh]/, @h).gsub(/%[Mm]/, @m).gsub(/%[Ss]/, @s).gsub("%%", "%")
  end