docs: def guess_timefmt(datestr):
      """
      Try to guess the format a date is written in.
  
      The following formats are supported:
  
      ================= ============== ===============
      Format            Example        Python format
      ----------------- -------------- ---------------
      ``YYYY-MM-DD``    2002-04-21     %Y-%m-%d
      ``YYYY.MM.DD``    2002.04.21     %Y.%m.%d
      ``YYYY MM DD``    2002 04 21     %Y %m %d
      ``DD-MM-YYYY``    21-04-2002     %d-%m-%Y
      ``DD.MM.YYYY``    21.04.2002     %d.%m.%Y
      ``DD MM YYYY``    21 04 2002     %d %m %Y
      ``DD/MM/YYYY``    21/04/2002     %d/%m/%Y
      ================= ============== ===============
  
      These formats can also be used for seasonal (yearly recurring) time series.
      The year needs to be replaced by ``9999`` or another configurable year
      representing the seasonal year..
  
      The following formats are recognised depending on your locale setting.
      There is no guarantee that this will work.
  
      ================= ============== ===============
      Format            Example        Python format
      ----------------- -------------- ---------------
      ``DD-mmm-YYYY``   21-Apr-2002    %d-%b-%Y
      ``DD.mmm.YYYY``   21.Apr.2002    %d.%b.%Y
      ``DD mmm YYYY``   21 Apr 2002    %d %b %Y
      ``mmm DD YYYY``   Apr 21 2002    %b %d %Y
      ``Mmmmm DD YYYY`` April 21 2002  %B %d %Y
      ================= ============== ===============
  
      .. note::
          - The time needs to follow this definition without exception:
              `%H:%M:%S.%f`. A complete date and time should therefore look like
              this::
  
                  2002-04-21 15:29:37.522
  
          - Be aware that in a file with comma separated values you should not
            use a date format that contains commas.
      """
  
      if isinstance(datestr, float) or isinstance(datestr, int):
          return None
  
      seasonal_key = str(config.get('DEFAULT', 'seasonal_key', '9999'))
  
      #replace 'T' with space to handle ISO times.
      if datestr.find('T') > 0:
          dt_delim = 'T'
      else:
          dt_delim = ' '
  
      delimiters = ['-', '.', ' ', '/']
      formatstrings = [['%Y', '%m', '%d'],
                       ['%d', '%m', '%Y'],
                       ['%d', '%b', '%Y'],
                       ['XXXX', '%m', '%d'],
                       ['%d', '%m', 'XXXX'],
                       ['%d', '%b', 'XXXX'],
                       [seasonal_key, '%m', '%d'],
                       ['%d', '%m', seasonal_key],
                       ['%d', '%b', seasonal_key]]
  
      timeformats = ['%H:%M:%S.%f', '%H:%M:%S', '%H:%M', '%H:%M:%S.%f000Z', '%H:%M:%S.%fZ']
  
      # Check if a time is indicated or not
      for timefmt in timeformats:
          try:
              datetime.strptime(datestr.split(dt_delim)[-1].strip(), timefmt)
              usetime = True
              break
          except ValueError:
              usetime = False
  
      # Check the simple ones:
      for fmt in formatstrings:
          for delim in delimiters:
              datefmt = fmt[0] + delim + fmt[1] + delim + fmt[2]
              if usetime:
                  for timefmt in timeformats:
                      complfmt = datefmt + dt_delim + timefmt
                      try:
                          datetime.strptime(datestr, complfmt)
                          return complfmt
                      except ValueError:
                          pass
              else:
                  try:
                      datetime.strptime(datestr, datefmt)
                      return datefmt
                  except ValueError:
                      pass
  
      # Check for other formats:
      custom_formats = ['%d/%m/%Y', '%b %d %Y', '%B %d %Y','%d/%m/XXXX', '%d/%m/'+seasonal_key]
  
      for fmt in custom_formats:
          if usetime:
              for timefmt in timeformats:
                  complfmt = fmt + dt_delim + timefmt
                  try:
                      datetime.strptime(datestr, complfmt)
                      return complfmt
                  except ValueError:
                      pass
  
          else:
              try:
                  datetime.strptime(datestr, fmt)
                  return fmt
              except ValueError:
                  pass
  
      return None