What code do you use to generate the text to go into the HTML title tag?

Mine is:

  function getDocumentTitle($separator = " « "){

    $title = get_bloginfo('name');
    $desc = get_bloginfo('description');

    if(is_front_page() && is_home() && !empty($desc)){
      $title .= $separator.$desc;

    }elseif(is_home() || is_singular()){
      $id = $GLOBALS['wp_query']->get_queried_object_id();
      if($meta = get_post_meta($id, 'title', true)) $title .= $separator.$meta;
      $title .= (empty($meta) && is_front_page() && !empty($desc)) ? $separator.$desc : $separator.get_post_field('post_title', $id);

    }elseif(is_archive()){    
      if(is_category() || is_tag() || is_tax()){
        $term = $GLOBALS['wp_query']->get_queried_object();
        $title .= $separator.$term->name;

      }elseif(is_author()){
        $title .= $separator.get_the_author_meta('display_name', get_query_var('author'));

      }elseif(is_date()){
        if(is_day())
          $title .= $separator.sprintf(_a('Archive for %s'), get_the_time(apply_filters('doc_title_archive_day_format', 'F jS, Y')));
        elseif(get_query_var('w'))
          $title .= $separator.$separator.sprintf(_a('Archive for week %1$s of %2$s'), get_the_time('W'), get_the_time('Y'));

        elseif(is_month())
          $title .= $separator.sprintf(_a('Archive for %s'), single_month_title(' ', false));
        elseif(is_year())
          $title .= $separator.sprintf(_a('Archive for year %s'), get_the_time('Y'));

      }else{
        $title .= $separator.post_type_archive_title('', false);

      }

    }elseif(is_search()){
      $title .= $separator.sprintf(_a('Search results for %s'), '"'.get_search_query().'"');

    }elseif(is_404()){
      $title .= $separator._a('404 Not Found');

    }

    // paged?
    if((($page = $GLOBALS['wp_query']->get('paged')) || ($page = $GLOBALS['wp_query']->get('page'))) && $page > 1 && !is_404())
      $title .= $separator.sprintf(_a('Page %s'), $page);

    // comment page?
    if(get_query_var('cpage'))
      $title .= $separator.sprintf(_a('Comment Page %s'), get_query_var('cpage'));

    // apply the wp_title filters so we're compatible with plugins
    return apply_filters('wp_title', $title, $separator, '');
  }

error code: 523