text: from datetime import datetime
  from datetime import timedelta
  
  import os
  import urllib.request
  import re
  
  SHUTDOWN_EVENT = 'Shutdown initiated'
  
  # prep: read in the logfile
  tmp = os.getenv("TMP", "/tmp")
  logfile = os.path.join(tmp, 'log')
  urllib.request.urlretrieve(
      'https://bites-data.s3.us-east-2.amazonaws.com/messages.log',
      logfile
  )
  
  with open(logfile) as f:
      loglines = f.readlines()
  
  mydate=[]
  
         
  
  
  def convert_to_datetime(line):
      """TODO 1:
         Extract timestamp from logline and convert it to a datetime object.
         For example calling the function with:
         INFO 2014-07-03T23:27:51 supybot Shutdown complete.
         returns:
         datetime(2014, 7, 3, 23, 27, 51)
      """
      date_time_str = line.split(' ')[1]
      return (datetime.strptime(date_time_str, '%Y-%m-%dT%H:%M:%S'))
  
  
  
  def time_between_shutdowns(loglines):
      """TODO 2:
         Extract shutdown events ("Shutdown initiated") from loglines and
         calculate the timedelta between the first and last one.
         Return this datetime.timedelta object.
      """
      for i in loglines:
         if SHUTDOWN_EVENT  in i:
            mydate.append(convert_to_datetime(i))
      print (mydate[0],mydate[-1])
      print (type(mydate[-1]-mydate[0]))
      return (mydate[-1]-mydate[0])
      
  print (time_between_shutdowns(loglines))
  