import time


def _fmt_time(t):
  return '%dh %dmin %ds %dms' % (t // (60 * 60 * 1000), t // (60 * 1000), t // 1000, t % 1000)


class Timer:
  def __init__(self):
    self.last  = 0
    self.total = 0

  def start(self):
    self.last = int(round(time.time() * 1000))

  def lap(self):
    t = int(round(time.time() * 1000))
    d = t - self.last
    self.last = t
    self.total += d
    return _fmt_time(d), _fmt_time(self.total)

@@ -31,43 +31,56 @@
 :%0A  
-return '%25dh %25dmin %25ds %25dms' %25
+hours   = t // (60 * 60 * 1000)%0A  mins    =
  (t 
-//
+%25
  (60
@@ -88,27 +88,25 @@
 * 60 * 1000)
-, t
+)
  // (60 * 10
@@ -112,29 +112,124 @@
 000)
-, t // 1000, t %25 1000
+%0A  secs    = (t %25 60 * 1000) // 1000%0A  millis  = t %25 1000%0A  return '%25dh %25dmin %25ds %25dms' %25 (hours, mins, secs, millis
 )%0A%0A%0A

Fix elapsed time formatting