docs: def timestr2time(time_str):
      '''
      Turns a string into a datetime.time object. This will only work if the 
      format can be "guessed", so the string must have one of the formats from
      VALID_TIME_FORMATS_TEXT.
  
      Args:
          time_str (str) a string that represents a date
      Returns:
          datetime.time object
      Raises:
          ValueError if the input string does not have a valid format.
      '''
      if any(c not in '0123456789:' for c in time_str):
          raise ValueError('Illegal character in time string')
      if time_str.count(':') == 2:
          h, m, s = time_str.split(':')
      elif time_str.count(':') == 1:
          h, m = time_str.split(':')
          s = '00'
      elif len(time_str) == 6:
          h = time_str[:2]
          m = time_str[2:4]
          s = time_str[4:]
      else:
          raise ValueError('Time format not recognised. {}'.format(
                  VALID_TIME_FORMATS_TEXT))
      if len(m) == 2 and len(s) == 2:
          mins = int(m)
          sec = int(s)
      else:
          raise ValueError('m and s must be 2 digits')
      try:
          return datetime.time(int(h), mins, sec)
      except ValueError:
          raise ValueError('Invalid time {}. {}'.format(time_str, 
                  VALID_TIME_FORMATS_TEXT))