Catch invalid month/day in "time data does not match format"
<p>I'm converting a date string using the following (not the full code, just the relevant bit):</p>

<pre><code>str_format = '%Y-%m-%d %H:%M:%S'
datetime.strptime('2015-13-23 13:43:23', str_format)
</code></pre>

<p>This throws a "time data does not match format" because the month is wrong (13 is not a valid month).</p>

<p>I was wondering if it was possible to have it raise an exception on the month (or day) being invalid <em>instead</em> of the format not matching because of the invalid date? The following clearly shows that datetime can determine that:</p>

<pre><code>&gt;&gt;&gt; print datetime(2015, 13, 23)
Traceback (most recent call last):
  File "&lt;stdin&gt;", line 1, in &lt;module&gt;
ValueError: month must be in 1..12
</code></pre>