title: localtime() gets it wrong, says date = September 31
body: <p>I am making a calendar program. The 'expand repeating events' code is giving me no end of trouble. I am expanding events by using mktime() to get a 'pure' time value, then adding the repeat delta (in this case, 604800 seconds or 7 days) to it. localtime() is then used to get a calendar struct back out.</p>
  
  <p>This happens:</p>
  
  <p>Original event: September 10</p>
  
  <pre><code>{tm_sec = 0, tm_min = 0, tm_hour = 16, tm_mday = 10, tm_mon = 9,
   tm_year = 2012, tm_wday = 4, tm_yday = 283, tm_isdst = 0, 
   tm_gmtoff = -25200, tm_zone = 0x608ff0 "PDT"}
  </code></pre>
  
  <p>First repetition: September 17</p>
  
  <pre><code>{tm_sec = 0, tm_min = 0, tm_hour = 17, tm_mday = 17, tm_mon = 9,
   tm_year = 2012, tm_wday = 4, tm_yday = 290, tm_isdst = 1, 
   tm_gmtoff = -25200, tm_zone = 0x608ff0 "PDT"}
  </code></pre>
  
  <p>Second repetition: September 24</p>
  
  <pre><code>{tm_sec = 0, tm_min = 0, tm_hour = 16, tm_mday = 24, tm_mon = 9,
   tm_year = 2012, tm_wday = 4, tm_yday = 297, tm_isdst = 0,
   tm_gmtoff = -25200, tm_zone = 0x608ff0 "PDT"}
  </code></pre>
  
  <p>Third repetition: September 31?!</p>
  
  <pre><code>{tm_sec = 0, tm_min = 0, tm_hour = 16, tm_mday = 31, tm_mon = 9,
   tm_year = 2012, tm_wday = 4, tm_yday = 304, tm_isdst = 0,
   tm_gmtoff = -25200, tm_zone = 0x608ff0 "PDT"}
  </code></pre>
  
  <p>Does anyone have any idea what's going on here? Will I have to fill in for <code>localtime()</code> myself?</p>