title: Python datetime to decimal year: one day off, where is the bug?
body: <p>I implemented a <code>datetime.datetime</code> to decimal year (year fraction) converter based on a <a href="https://stackoverflow.com/questions/6451655/python-how-to-convert-datetime-dates-to-decimal-years">previous answer</a>. I am not getting the expected results but I can't find the bug.</p>
  
  <pre><code>from datetime import datetime, timedelta
  
  def decimal_year_to_datetime(decimal_year_float):
      year = int(decimal_year_float)
      remain = decimal_year_float - year
      base = datetime(year, 1, 1)
      whole_year_time_delta = (base.replace(year=base.year + 1) - base)
      fractional_seconds = whole_year_time_delta.total_seconds() * remain
      our_time_delta = timedelta(seconds=fractional_seconds)
      result = base + our_time_delta
      return result
  
  def test_conversion():
      year = 2013
      month = 1
      day = 1
      hour = 2
      minute = 16
      second = 48
      date = datetime(year=year, month=month, day=day)
      fraction_of_the_day = (hour + (minute + second / 60.0) / 60.0) / 24.
      days_in_year = (date.replace(year=date.year + 1) - date).days
      dec_yr = year + (date.timetuple().tm_yday + 
                       fraction_of_the_day) / float(days_in_year)
  
      expect_date = datetime(year=year, month=month, day=day, 
                                hour=hour, minute=minute, second=second)
  
      got_date = decimal_year_to_datetime(dec_yr)
  
      assert(got_date == expect_date)
  
  if __name__ == '__main__':
      test_conversion()
  </code></pre>
  
  <p>I seem to be a day (an and a fraction of a second) off with my conversion. But I cannot see the bug.</p>
  
  <p>Have I missed something obvious?</p>