title: Add or subtract an interval from a timeval
body: <p>I've seen a number of questions / answers for subtracting two datetimes here but not one for adding or subtracting an interval to / from a timevalue.</p>
  <p><a href="https://stackoverflow.com/questions/43491225/add-milliseconds-to-timeval-c">Add milliseconds to timeval C++</a> This asnwer does not result in a valid timeval structure.</p>
  <pre class="lang-c prettyprint-override"><code>void addms2timeval(int microseconds, timeval tv); //prototype (doesn't exist yet)
  ...
      struct timeval later; 
      gettimeofday(&amp;later, NULL);
      addms2timeval(1000, later);
      //later is now 1000 us in the future. 
  
  </code></pre>
  <p>Also doesn't seem to be part of the standard C libraries unless I missed it.
  <a href="https://pubs.opengroup.org/onlinepubs/007908775/xsh/systime.h.html" rel="nofollow noreferrer">https://pubs.opengroup.org/onlinepubs/007908775/xsh/systime.h.html</a>
  <a href="https://www.gnu.org/software/libc/manual/html_node/Date-and-Time.html" rel="nofollow noreferrer">https://www.gnu.org/software/libc/manual/html_node/Date-and-Time.html</a></p>
  <p>Perhaps it's trivial, but it seems like one of those things that you can <em>think</em> you coded correctly but which then fails randomly every so often due to over / under flows.</p>
  <p>Has anyone written and tested this?</p>