title: Get last day of month in python
body: <p>Getting error for December month.  </p>
  
  <blockquote>
    <p>ValueError: month must be in 1..12</p>
  </blockquote>
  
  <pre><code>def last_day_of_month(ds):
      cur_ds = datetime.strptime(ds, '%Y-%m-%d')
      next_month = datetime(year=cur_ds.year, month=cur_ds.month+1, day=1)
      last_day_month = next_month - timedelta(days=1)
      return datetime.strftime(last_day_month, '%Y-%m-%d')
  
  print last_day_of_month('2016-12-01')
  </code></pre>