class_docstr: Validate and parse dates using the `dateutil` package.
docstr: Return either t_dtype.DTYPE_DATE or t_dtype.DTYPE_TIME depending on
  the format of the parsed date.
  
  If the parsed date is invalid, return t_dtype.DTYPE_STR to prevent
  further attempts at conversion.  Attempt to use heuristics about dates
  to minimize false positives, i.e. do not parse dates without separators.
  
  Args:
      datestring (:obj:'str'): the datestring to parse.
docstr_tok: ["Return","either","t_dtype.DTYPE_DATE","or","t_dtype.DTYPE_TIME","depending","on","the","format","of","the","parsed","date",".","If","the","parsed","date","is","invalid",",","return","t_dtype.DTYPE_STR","to","prevent","further","attempts","at","conversion",".","Attempt","to","use","heuristics","about","dates","to","minimize","false","positives",",","i.e",".","do","not","parse","dates","without","separators",".","Args",":","datestring","(",":","obj",":","'str","'",")",":","the","datestring","to","parse","."]
code: def format(self, datestring):
      """Return either t_dtype.DTYPE_DATE or t_dtype.DTYPE_TIME depending on
      the format of the parsed date.
  
      If the parsed date is invalid, return t_dtype.DTYPE_STR to prevent
      further attempts at conversion.  Attempt to use heuristics about dates
      to minimize false positives, i.e. do not parse dates without separators.
  
      Args:
          datestring (:obj:'str'): the datestring to parse.
      """
      if isinstance(datestring, (bytes, bytearray)):
          datestring = datestring.decode("utf-8")
      has_separators = bool(
          search(r"[/. -]", datestring)
      )  # match commonly-used date separators
      # match commonly-used date separators
  
      dtype = t_dtype.DTYPE_STR
  
      if has_separators:
          try:
              parsed = parse(datestring)
              if (
                  parsed.hour,
                  parsed.minute,
                  parsed.second,
                  parsed.microsecond,
              ) == (
                  0,
                  0,
                  0,
                  0,
              ):
                  dtype = t_dtype.DTYPE_DATE
              else:
                  dtype = t_dtype.DTYPE_TIME
          except (ValueError, OverflowError, TypeError):
              # unparsable dates should be coerced to string
              dtype = t_dtype.DTYPE_STR
  
      return dtype
  
file_path: perspective/python/perspective/perspective/table/_date_validator.py
imports: import numpy
  from calendar import timegm
  from datetime import date, datetime
  from dateutil.parser import parse
  from pytz import UTC
  from pandas import Period
  from re import search
  from time import mktime
  from .libpsppy import t_dtype
label_desc: Use image node_id 4 for calling the _PerspectiveDateValidator obj's underlying member method code with example usage: obj.format(datestring) and returns: dtype