title: From milliseconds to hour, minutes, seconds and milliseconds
body: <p>I need to go from milliseconds to a tuple of (hour, minutes, seconds, milliseconds) representing the same amount of time. E.g.:</p>
  
  <p>10799999ms = 2h 59m 59s 999ms</p>
  
  <p>The following pseudo-code is the only thing I could come up with: </p>
  
  <pre><code># The division operator below returns the result as a rounded down integer
  function to_tuple(x):
      h = x / (60*60*1000)
      x = x - h*(60*60*1000)
      m = x / (60*1000)
      x = x - m*(60*1000)
      s = x / 1000
      x = x - s*1000
      return (h,m,s,x)
  </code></pre>
  
  <p>I'm sure it must be possible to do it smarter/more elegant/faster/more compact. </p>