title: python: how to convert "x days ago" or "x month ago" to date?
body: <p>How to convert the following statements to dates (no time need) in python?</p>
  
  <pre><code>10 days ago
  about 2 months ago
  </code></pre>
  
  <p>Here are the code I made so far:</p>
  
  <pre><code>import re
  from datetime import datetime, timedelta
  
  def string_to_delta(s):
      value = int(re.search(r'\d+', s).group())
      if "day" in s:
          value = value*1
      elif "month" in s:
          value = value *30   
      date_ago = (datetime.now() - timedelta(days=value)).date() 
      str_date= date_ago.strftime("%d %B %Y")
      return str_date
  </code></pre>
  
  <p>It worked, but I feel awkward.  </p>