code: def parse_local_date(date_str: str) -> dt.datetime:
      """Parses common date string formats to local datetime objects."""
      if isinstance(date_str, dt.datetime):
          return date_str
      date_formats = [
          "%Y-%m-%d %H:%M:%S.%f",
          "%Y-%m-%d %H:%M:%S",
          "%Y-%m-%d",
      ]
  
      date = None
      for date_format in date_formats:
          try:
              date = dt.datetime.strptime(date_str, date_format)
          except ValueError:
              pass
      if date is None:
          raise ValueError(f"Can't parse date: {date_str}")
      return date
  
imports: import datetime
  import pytz
  import re
label_desc: Use image node_id 1 for calling a global function with example usage: parse_local_date(date_str) and returns: date, date_str