def fmt_ms(t):                                                  # {{{1
  """
  format time (in s) as ms

  >>> import trcrt as T
  >>> T.fmt_ms(7.654321)
  '7654'
  >>> T.fmt_ms(0.654321)
  '654'
  >>> T.fmt_ms(0.054321)
  '54.3'
  >>> T.fmt_ms(0.004321)
  '4.32'
  >>> T.fmt_ms(0.000321)
  '0.321'
  >>> T.fmt_ms(0.000021)
  '0.021'
  >>> T.fmt_ms(0.000001)
  '0.001'
  """

  tu, tm = int(t * 10**6), int(t * 10**3)
  if tu >= 10**5:
    return "{:d}".format(tm)
  elif tu >= 10**4:
    return "{:d}.{:01d}".format(tm, (tu%1000)//100)
  elif tu >= 10**3:
    return "{:d}.{:02d}".format(tm, (tu%1000)//10)
  else:
    return "0.{:03d}".format(tu)
                                                                # }}}1