title: How to determine appropriate strftime format from a date string?
body: <p>The <code>dateutil</code> parser does a great job of correctly guessing the date and time from a wide variety of sources. </p>
  
  <p>We are processing files in which each file uses only one date/time format, but the format varies between files. Profiling shows a lot of time being used by <code>dateutil.parser.parse</code>.  Since it only needs to be determined once per file, implementing something that isn't guessing the format each time could speed things up. </p>
  
  <p>I don't actually know the formats in advance and I'll still need to infer the format.  Something like:</p>
  
  <pre><code>from MysteryPackage import date_string_to_format_string
  import datetime
  
  # e.g. mystring = '1 Jan 2016'
  myformat = None
  
  ...
  
  # somewhere in a loop reading from a file or connection:
  if myformat is None:
      myformat = date_string_to_format_string(mystring)
  
  # do the usual checks to see if that worked, then:
  mydatetime = datetime.strptime(mystring, myformat)
  </code></pre>
  
  <p>Is there such a function?</p>