act.utils.date_parser

act.utils.date_parser(date_string, output_format='%Y%m%d', return_datetime=False)[source]

Converts one datetime string to another or to a datetime object.

Parameters:
  • date_string (str) – datetime string to be parsed. Accepted formats are YYYY-MM-DD, DD.MM.YYYY, DD/MM/YYYY or YYYYMMDD.

  • output_format (str) – Format for datetime.strftime to output datetime string.

  • return_datetime (bool) – If true, returns str as a datetime object. Default is False.

Returns:

  • datetime_str (str) – A valid datetime string.

  • datetime_obj (datetime.datetime) – A datetime object.