code: def create_event(component, tz=UTC):
      
  
      event = Event()
  
      event.start = normalize(component.get('dtstart').dt, tz=tz)
      
      if component.get('dtend'):
          event.end = normalize(component.get('dtend').dt, tz=tz)
      elif component.get('duration'): # compute implicit end as start + duration
          event.end = event.start + component.get('duration').dt
      else: # compute implicit end as start + 0
          event.end = event.start
      
      try:
          event.summary = str(component.get('summary'))
      except UnicodeEncodeError as e:
          event.summary = str(component.get('summary').encode('utf-8'))
      try:
          event.description = str(component.get('description'))
      except UnicodeEncodeError as e:
          event.description = str(component.get('description').encode('utf-8'))
      event.all_day = type(component.get('dtstart').dt) is date
      if component.get('rrule'):
          event.recurring = True
      try:
          event.location = str(component.get('location'))
      except UnicodeEncodeError as e:
          event.location = str(component.get('location').encode('utf-8'))
  
      if component.get('attendee'):
          event.attendee = component.get('attendee')
          if type(event.attendee) is list:
              temp = []
              for a in event.attendee:
                  temp.append(a.encode('utf-8').decode('ascii'))
              event.attendee = temp
          else:
              event.attendee = event.attendee.encode('utf-8').decode('ascii')
  
      if component.get('uid'):
          event.uid = component.get('uid').encode('utf-8').decode('ascii')
  
      if component.get('organizer'):
          event.organizer = component.get('organizer').encode('utf-8').decode('ascii')
  
      return event
docs: Create an event from its iCal representation.
  
      :param component: iCal component
      :param tz: timezone for start and end times
      :return: event