title: Converting epoch time to "real" date/time
body: <p>What I want to do is convert an epoch time (seconds since midnight 1/1/1970) to "real" time (m/d/y h:m:s)</p>
  
  <p>So far, I have the following algorithm, which to me feels a bit ugly:</p>
  
  <pre><code>void DateTime::splitTicks(time_t time) {
      seconds = time % 60;
      time /= 60;
      minutes = time % 60;
      time /= 60;
      hours = time % 24;
      time /= 24;
  
      year = DateTime::reduceDaysToYear(time);
      month = DateTime::reduceDaysToMonths(time,year);
      day = int(time);
  }
  
  int DateTime::reduceDaysToYear(time_t &amp;days) {
      int year;
      for (year=1970;days&gt;daysInYear(year);year++) {
          days -= daysInYear(year);
      }
      return year;
  }
  
  int DateTime::reduceDaysToMonths(time_t &amp;days,int year) {
      int month;
      for (month=0;days&gt;daysInMonth(month,year);month++)
          days -= daysInMonth(month,year);
      return month;
  }
  </code></pre>
  
  <p>you can assume that the members <code>seconds</code>, <code>minutes</code>, <code>hours</code>, <code>month</code>, <code>day</code>, and <code>year</code> all exist.</p>
  
  <p>Using the <code>for</code> loops to modify the original time feels a little off, and I was wondering if there is a "better" solution to this.</p>