title: Calculate starting time and duration of a digital signal in python
body: <p>I am having a hard "time" trying to use <code>time</code> and <code>datetime</code> in Python to achive a fairly simple goal. I have already worked with those modules, and have read documentation, but I think I am not getting it the right way.</p>
  
  <p>I have a digital signal (a long array) which represents a time series recorded with a given sampling rate, say, N samples per second.</p>
  
  <p>I have a list of tuples in the following format (dummy data):</p>
  
  <pre><code>[(150, 150),
   (450, 90),
   (750, 150),
   (1050, 90),
   (1350, 150),
   (1650, 90),
   ...
   (1950, 150)]
  </code></pre>
  
  <p>Each tuple represents starting sample and number of samples of a given interval. Intervals are consecutive, so starting sample is monotonically increasing.</p>
  
  <p>What I want is to get strings representing starting time and duration the interval (since each sample has a fixed known duration, determined by sampling rate), like this:</p>
  
  <pre><code>[('00:12.000', '2.245'),
   ('00:15.057', '2.158'),
   ('00:18.857', '3.045'),
   etc.]
  </code></pre>
  
  <p>(IMPORTANT: these values are not intended for calculation, just to give an idea of structure and formatting. The values are arbitrarily typed numbers)</p>
  
  <p>I can imagine very ugly ways to get this with rounding and subtraction and modulo division and the like, but I think Python, with all those beautiful time manipulation modules, MUST have a pythonic way to get what I need.</p>
  
  <p>Anyone?</p>
  
  <p>Thanks for reading!
  (and hope the coming answers might enlighten the path of other people in the future)</p>