relative date in comments

  1. function tassoman_comment_view($comment, $links = array(), $visible = 1) {
  2.   static $first_new = TRUE;
  3.        
  4.         // comment time difference
  5.         static $comment_previous_timestamp;
  6.         $n = node_load($comment->nid);
  7.         if(! $comment_previous_timestamp) $comment_previous_timestamp = $n->created;
  8.         $comment_difference_timestamp = $comment->timestamp - $comment_previous_timestamp;
  9.         $comment->previous_difference = format_interval($comment_difference_timestamp);
  10.         $comment_previous_timestamp = $comment->timestamp;
  11.        
  12.   $output = '';
  13.   $comment->new = node_mark($comment->nid, $comment->timestamp);
  14.   if ($first_new && $comment->new != MARK_READ) {
  15.     // Assign the anchor only for the first new comment. This avoids duplicate
  16.     // id attributes on a page.
  17.     $first_new = FALSE;
  18.     $output .= "<a id=\"new\"></a>\n";
  19.   }
  20.  
  21.   $output .= "<a id=\"comment-$comment->cid\"></a>\n";
  22.  
  23.   // Switch to folded/unfolded view of the comment
  24.   if ($visible) {
  25.     $comment->comment = check_markup($comment->comment, $comment->format, FALSE);
  26.  
  27.     // Comment API hook
  28.     comment_invoke_comment($comment, 'view');
  29.  
  30.     $output .= theme('comment', $comment, $links);
  31.   }
  32.   else {
  33.     $output .= theme('comment_folded', $comment);
  34.   }
  35.        
  36.   return $output;
  37. }