title: Python daysBetweenDate
body: <p>I think I might have an infinite loop because I keep getting back an error message whenever I run the code, it says "program shut down for using 13 CPU seconds." </p>
  
  <p>The entire code, should take a date as input and output the next day, this code assumes all months are 30 days. Aside from the <code>daysBetweenDates</code> function, everything else seems to be working fine. Does anyone have any suggestions? Or maybe someone can tell me what I'm missing?</p>
  
  <pre><code>def daysInMonth(year, month):
          return 30
  
  def nextDay(year, month, day):
      if day &lt; 30:
          return year, month, day + 1
      else:
          if month == 12:
              return year + 1, 1, 1
          else:
              return year, month + 1, 1
          return
  
  def dateIsBefore(year1, month1, day1, year2, month2, day2):
      if year1 &lt; year2:
          return True  
  
  def daysBetweenDates(year1, month1, day1, year2, month2, day2):
      days = 0
      while dateIsBefore(year1, month1, day1, year2, month2, day2):
          days += 1
      return days
  
  def test():
      test_cases = [((2012,1,1,2012,2,28), 58),
                    ((2012,1,1,2012,3,1), 60),
                    ((2011,6,30,2012,6,30), 366),
                    ((2011,1,1,2012,8,8), 585 ),
                    ((1900,1,1,1999,12,31), 36523)]
      for (args, answer) in test_cases:
          result = daysBetweenDates(*args)
          if result != answer:
              print "Test with data:", args, "failed"
              print result
          else:
              print "Test case passed!"
  test()
  </code></pre>