code: def parseIBDatetime(s: str) -> Union[dt.date, dt.datetime]:
      """Parse string in IB date or datetime format to datetime."""
      if len(s) == 8:
          # YYYYmmdd
          y = int(s[0:4])
          m = int(s[4:6])
          d = int(s[6:8])
          t = dt.date(y, m, d)
      elif s.isdigit():
          t = dt.datetime.fromtimestamp(int(s), dt.timezone.utc)
      elif s.count(" ") >= 2 and "  " not in s:
          # 20221125 10:00:00 Europe/Amsterdam
          s0, s1, s2 = s.split(" ", 2)
          t = dt.datetime.strptime(s0 + s1, "%Y%m%d%H:%M:%S")
          t = t.replace(tzinfo=ZoneInfo(s2))
      else:
          # YYYYmmdd  HH:MM:SS
          # or
          # YYYY-mm-dd HH:MM:SS.0
          ss = s.replace(" ", "").replace("-", "")[:16]
          t = dt.datetime.strptime(ss, "%Y%m%d%H:%M:%S")
      return t
  
imports: import asyncio
  import datetime
  import logging
  import math
  import signal
  import sys
  import time
  from dataclasses import fields, is_dataclass
  from typing import AsyncIterator, Awaitable, Callable, Iterator, List, Optional, Union
  import eventkit
label_desc: Use image node_id 26 for calling a global function with example usage: parseIBDatetime(s) and returns: t