code: def datetime_from_iso8601(date):
      
      format = ISO8610_FORMAT
      if date.endswith("Z"):
          date = date[:-1]  # Date date is UTC
      if re.match(".*\.\d+", date):
          # Date includes microseconds
          format = ISO8610_FORMAT_MICROSECONDS
      return datetime.datetime.strptime(date, format)
docs: Small helper that parses ISO-8601 date dates.
  
          >>> datetime_from_iso8601("2013-04-10T12:52:39")
          datetime.datetime(2013, 4, 10, 12, 52, 39)
          >>> datetime_from_iso8601("2013-01-07T12:55:19.257")
          datetime.datetime(2013, 1, 7, 12, 55, 19, 257000)