title: Comparing dates and finding the closest date to the current date
body: <p>I'm looking to compare a list of dates with todays date and would like to return the closest one. Ive had various ideas on it but they are seem very convoluted and involve scoring based on how many days diff and taking the smallest diff. But I have no clue how to do this simply any pointers would be appreciated.</p>
  
  <pre><code>import datetime
  import re
  
  date_list = ['2019-02-10', '2018-01-13', '2019-02-8',]
  now = datetime.date.today()
  
  for date_ in date_list:
      match = re.match('.*(\d{4})-(\d{2})-(\d{2}).*', date_)
      if match:
          year = match.group(1)
          month = match.group(2)
          day = match.group(3)
          delta = now - datetime.date(int(year), int(month), int(day))
          print(delta)
  </code></pre>
  
  <p><strong><em>As I was Waiting EDIT</em></strong></p>
  
  <p>So I solved this using the below</p>
  
  <pre><code>import datetime
  import re
  
  date_list = ['2019-02-10', '2018-01-13', '2019-02-8',]
  now = datetime.date.today()
  
  for date_ in date_list:
      match = re.match('.*(\d{4})-(\d{2})-(\d{2}).*', date_)
      if match:
          year = match.group(1)
          month = match.group(2)
          day = match.group(3)
          delta = now - datetime.date(int(year), int(month), int(day))
  
  dates_range.append(int(delta.days))
  days = min(s for s in dates_range)
  </code></pre>