Index: formatting.php
===================================================================
--- formatting.php	(revision 6597)
+++ formatting.php	(working copy)
@@ -1,5 +1,20 @@
 <?php
+/**
+ * 
+ *
+ * @package WordPress
+ */
 
+/**
+ * wptexturize() - {@internal Missing Short Description}}
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since 0.71
+ *
+ * @param unknown_type $text
+ * @return unknown
+ */
 function wptexturize($text) {
 	global $wp_cockneyreplace;
 	$next = true;
@@ -24,7 +39,7 @@
 	$dynamic_replacements = array('&#8217;$1','$1&#8216;', '$1&#8243;', '$1&#8242;', '$1&#8217;$2', '$1&#8220;$2', '&#8221;$1', '&#8217;$1', '$1&#215;$2');
 
 	for ( $i = 0; $i < $stop; $i++ ) {
- 		$curl = $textarr[$i];
+		$curl = $textarr[$i];
 
 		if (isset($curl{0}) && '<' != $curl{0} && $next) { // If it's not a tag
 			// static strings
@@ -41,11 +56,19 @@
 		$output .= $curl;
 	}
 
-  	return $output;
+	return $output;
 }
 
-// Accepts matches array from preg_replace_callback in wpautop()
-// or a string
+/**
+ * clean_pre() - Accepts matches array from preg_replace_callback in wpautop() or a string
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since 1.2.0
+ *
+ * @param unknown_type $matches
+ * @return unknown
+ */
 function clean_pre($matches) {
 	if ( is_array($matches) )
 		$text = $matches[1] . $matches[2] . "</pre>";
@@ -59,6 +82,17 @@
 	return $text;
 }
 
+/**
+ * wpautop() - {@internal Missing Short Description}}
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since 0.71
+ *
+ * @param unknown_type $pee
+ * @param unknown_type $br
+ * @return unknown
+ */
 function wpautop($pee, $br = 1) {
 	$pee = $pee . "\n"; // just to make things a little easier, pad the end
 	$pee = preg_replace('|<br />\s*<br />|', "\n\n", $pee);
@@ -92,7 +126,16 @@
 	return $pee;
 }
 
-
+/**
+ * seems_utf8() - {@internal Missing Short Description}}
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since 1.2.1
+ *
+ * @param unknown_type $Str
+ * @return unknown
+ */
 function seems_utf8($Str) { # by bmorel at ssi dot fr
 	$length = strlen($Str);
 	for ($i=0; $i < $length; $i++) {
@@ -111,6 +154,17 @@
 	return true;
 }
 
+/**
+ * wp_specialchars() - {@internal Missing Short Description}}
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since 1.2.2
+ *
+ * @param unknown_type $text
+ * @param unknown_type $quotes
+ * @return unknown
+ */
 function wp_specialchars( $text, $quotes = 0 ) {
 	// Like htmlspecialchars except don't double-encode HTML entities
 	$text = str_replace('&&', '&#038;&', $text);
@@ -129,6 +183,17 @@
 	return $text;
 }
 
+/**
+ * utf8_uri_encode() - {@internal Missing Short Description}}
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since 1.5.0
+ *
+ * @param unknown_type $utf8_string
+ * @param unknown_type $length
+ * @return unknown
+ */
 function utf8_uri_encode( $utf8_string, $length = 0 ) {
 	$unicode = '';
 	$values = array();
@@ -170,6 +235,16 @@
 	return $unicode;
 }
 
+/**
+ * remove_accents() - {@internal Missing Short Description}}
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since 1.2.1
+ *
+ * @param unknown_type $string
+ * @return unknown
+ */
 function remove_accents($string) {
 	if ( !preg_match('/[\x80-\xff]/', $string) )
 		return $string;
@@ -300,6 +375,16 @@
 	return $string;
 }
 
+/**
+ * sanitize_file_name() - {@internal Missing Short Description}}
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since 2.1.0
+ *
+ * @param unknown_type $name
+ * @return unknown
+ */
 function sanitize_file_name( $name ) { // Like sanitize_title, but with periods
 	$name = strtolower( $name );
 	$name = preg_replace('/&.+?;/', '', $name); // kill entities
@@ -311,6 +396,17 @@
 	return $name;
 }
 
+/**
+ * sanitize_user() - {@internal Missing Short Description}}
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since 2.0.0
+ *
+ * @param unknown_type $username
+ * @param unknown_type $strict
+ * @return unknown
+ */
 function sanitize_user( $username, $strict = false ) {
 	$raw_username = $username;
 	$username = strip_tags($username);
@@ -325,6 +421,17 @@
 	return apply_filters('sanitize_user', $username, $raw_username, $strict);
 }
 
+/**
+ * sanitize_title() - {@internal Missing Short Description}}
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since 1.0.0
+ *
+ * @param unknown_type $title
+ * @param unknown_type $fallback_title
+ * @return unknown
+ */
 function sanitize_title($title, $fallback_title = '') {
 	$title = strip_tags($title);
 	$title = apply_filters('sanitize_title', $title);
@@ -335,6 +442,16 @@
 	return $title;
 }
 
+/**
+ * sanitize_title_with_dashes() - {@internal Missing Short Description}}
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since 1.2.0
+ *
+ * @param unknown_type $title
+ * @return unknown
+ */
 function sanitize_title_with_dashes($title) {
 	$title = strip_tags($title);
 	// Preserve escaped octets.
@@ -362,6 +479,17 @@
 	return $title;
 }
 
+/**
+ * convert_chars() - {@internal Missing Short Description}}
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since 0.71
+ *
+ * @param unknown_type $content
+ * @param string $deprecated Not used
+ * @return string
+ */
 function convert_chars($content, $deprecated = '') {
 	// Translation of invalid Unicode references range to valid range
 	$wp_htmltranswinuni = array(
@@ -416,6 +544,16 @@
 	return $content;
 }
 
+/**
+ * funky_javascript_fix() - {@internal Missing Short Description}}
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since 1.5.0
+ *
+ * @param unknown_type $text
+ * @return unknown
+ */
 function funky_javascript_fix($text) {
 	// Fixes for browsers' javascript bugs
 	global $is_macIE, $is_winIE;
@@ -426,32 +564,43 @@
 	return $text;
 }
 
+/**
+ * balanceTags() - {@internal Missing Short Description}}
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since 0.71
+ *
+ * @param string $text Text to be balanced
+ * @param bool $force Forces balancing, ignoring the value of the option
+ * @return string Balanced text
+ */
 function balanceTags( $text, $force = false ) {
 	if ( !$force && get_option('use_balanceTags') == 0 )
 		return $text;
 	return force_balance_tags( $text );
 }
 
-/*
- force_balance_tags
-
- Balances Tags of string using a modified stack.
-
- @param text      Text to be balanced
- @param force     Forces balancing, ignoring the value of the option
- @return          Returns balanced text
- @author          Leonard Lin (leonard@acm.org)
- @version         v1.1
- @date            November 4, 2001
- @license         GPL v2.0
- @notes
- @changelog
- ---  Modified by Scott Reilly (coffee2code) 02 Aug 2004
-	1.2  ***TODO*** Make better - change loop condition to $text
-	1.1  Fixed handling of append/stack pop order of end text
-	     Added Cleaning Hooks
-	1.0  First Version
-*/
+/**
+ * force_balance_tags() - Balances tags of string using a modified stack.
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since 2.0.4
+ *
+ * @author Leonard Lin <leonard@acm.org>
+ * @license GPL v2.0
+ * @date November 4, 2001
+ * @version 1.1
+ * @todo Make better - change loop condition to $text in 1.2
+ * @internal Modified by Scott Reilly (coffee2code) 02 Aug 2004
+ *		1.1  Fixed handling of append/stack pop order of end text
+ *			 Added Cleaning Hooks
+ *		1.0  First Version
+ *
+ * @param string $text Text to be balanced
+ * @return string Balanced text
+ */
 function force_balance_tags( $text ) {
 	$tagstack = array(); $stacksize = 0; $tagqueue = ''; $newtext = '';
 	$single_tags = array('br', 'hr', 'img', 'input'); //Known single-entity/self-closing tags
@@ -551,6 +700,17 @@
 	return $newtext;
 }
 
+/**
+ * format_to_edit() - {@internal Missing Short Description}}
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since 0.71
+ *
+ * @param unknown_type $content
+ * @param unknown_type $richedit
+ * @return unknown
+ */
 function format_to_edit($content, $richedit = false) {
 	$content = apply_filters('format_to_edit', $content);
 	if (! $richedit )
@@ -558,30 +718,99 @@
 	return $content;
 }
 
+/**
+ * format_to_post() - {@internal Missing Short Description}}
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since 0.71
+ *
+ * @param unknown_type $content
+ * @return unknown
+ */
 function format_to_post($content) {
 	$content = apply_filters('format_to_post', $content);
 	return $content;
 }
 
-function zeroise($number,$threshold) { // function to add leading zeros when necessary
+/**
+ * zeroise() - Add leading zeros when necessary
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since 0.71
+ *
+ * @param mixed $number Will convert to string and add zeros
+ * @param int $threshold Amount of digits
+ * @return string Adds leading zeros to number if needed
+ */
+function zeroise($number,$threshold) {
 	return sprintf('%0'.$threshold.'s', $number);
 }
 
-
+/**
+ * backslashit() - {@internal Missing Short Description}}
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since 0.71
+ *
+ * @param unknown_type $string
+ * @return unknown
+ */
 function backslashit($string) {
 	$string = preg_replace('/^([0-9])/', '\\\\\\\\\1', $string);
 	$string = preg_replace('/([a-z])/i', '\\\\\1', $string);
 	return $string;
 }
 
+/**
+ * trailingslashit() - Appends a trailing slash
+ *
+ * Will remove trailing slash if it exists already before adding
+ * a trailing slash. This prevents double slashing a string or
+ * path.
+ *
+ * The primary use of this is for paths and thus should be used
+ * for paths. It is not restricted to paths and offers no specific
+ * path support.
+ *
+ * @since 1.2.0
+ * @uses untrailingslashit() Unslashes string if it was slashed already
+ *
+ * @param string $string What to add the trailing slash to
+ * @return string String with trailing slash added
+ */
 function trailingslashit($string) {
 	return untrailingslashit($string) . '/';
 }
 
+/**
+ * untrailingslashit() - Removes trailing slash if it exists
+ *
+ * The primary use of this is for paths and thus should be used
+ * for paths. It is not restricted to paths and offers no specific
+ * path support.
+ *
+ * @since 2.2.0
+ *
+ * @param string $string What to remove the trailing slash from
+ * @return string String without the trailing slash
+ */
 function untrailingslashit($string) {
 	return rtrim($string, '/');
 }
 
+/**
+ * addslashes_gpc() - {@internal Missing Short Description}}
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since 0.71
+ *
+ * @param unknown_type $gpc
+ * @return unknown
+ */
 function addslashes_gpc($gpc) {
 	global $wpdb;
 
@@ -592,23 +821,47 @@
 	return $wpdb->escape($gpc);
 }
 
-
+/**
+ * stripslashes_deep() - {@internal Missing Short Description}}
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since 2.0.0
+ *
+ * @param unknown_type $value
+ * @return unknown
+ */
 function stripslashes_deep($value) {
-	 $value = is_array($value) ?
-		 array_map('stripslashes_deep', $value) :
-		 stripslashes($value);
-
-	 return $value;
+	$value = is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value);
+	return $value;
 }
 
+/**
+ * urlencode_deep() - {@internal Missing Short Description}}
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since 2.2.0
+ *
+ * @param unknown_type $value
+ * @return unknown
+ */
 function urlencode_deep($value) {
-	 $value = is_array($value) ?
-		 array_map('urlencode_deep', $value) :
-		 urlencode($value);
-
-	 return $value;
+	$value = is_array($value) ? array_map('urlencode_deep', $value) : urlencode($value);
+	return $value;
 }
 
+/**
+ * antispambot() - {@internal Missing Short Description}}
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since 0.71
+ *
+ * @param unknown_type $emailaddy
+ * @param unknown_type $mailto
+ * @return unknown
+ */
 function antispambot($emailaddy, $mailto=0) {
 	$emailNOSPAMaddy = '';
 	srand ((float) microtime() * 1000000);
@@ -626,6 +879,17 @@
 	return $emailNOSPAMaddy;
 }
 
+/**
+ * _make_url_clickable_cb() - {@internal Missing Short Description}}
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since 2.5
+ * @access private
+ *
+ * @param unknown_type $matches
+ * @return unknown
+ */
 function _make_url_clickable_cb($matches) {
 	$url = $matches[2];
 	$url = clean_url($url);
@@ -634,6 +898,17 @@
 	return $matches[1] . "<a href=\"$url\" rel=\"nofollow\">$url</a>";
 }
 
+/**
+ * _make_web_ftp_clickable_cb() - {@internal Missing Short Description}}
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since 2.5
+ * @access private
+ *
+ * @param unknown_type $matches
+ * @return unknown
+ */
 function _make_web_ftp_clickable_cb($matches) {
 	$dest = $matches[2];
 	$dest = 'http://' . $dest;
@@ -644,11 +919,32 @@
 	return $matches[1] . "<a href=\"$dest\" rel=\"nofollow\">$dest</a>";
 }
 
+/**
+ * _make_email_clickable_cb() - {@internal Missing Short Description}}
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since 2.5
+ * @access private
+ *
+ * @param unknown_type $matches
+ * @return unknown
+ */
 function _make_email_clickable_cb($matches) {
 	$email = $matches[2] . '@' . $matches[3];
 	return $matches[1] . "<a href=\"mailto:$email\">$email</a>";
 }
 
+/**
+ * make_clickable() - {@internal Missing Short Description}}
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since 0.71
+ *
+ * @param unknown_type $ret
+ * @return unknown
+ */
 function make_clickable($ret) {
 	$ret = ' ' . $ret;
 	// in testing, using arrays here was found to be faster
@@ -661,6 +957,16 @@
 	return $ret;
 }
 
+/**
+ * wp_rel_nofollow() - {@internal Missing Short Description}}
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since 1.5.0
+ *
+ * @param unknown_type $text
+ * @return unknown
+ */
 function wp_rel_nofollow( $text ) {
 	global $wpdb;
 	// This is a pre save filter, so text is already escaped.
@@ -670,15 +976,35 @@
 	return $text;
 }
 
+/**
+ * wp_rel_nofollow_callback() - {@internal Missing Short Description}}
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since 2.3.0
+ *
+ * @param unknown_type $matches
+ * @return unknown
+ */
 function wp_rel_nofollow_callback( $matches ) {
 	$text = $matches[1];
 	$text = str_replace(array(' rel="nofollow"', " rel='nofollow'"), '', $text);
 	return "<a $text rel=\"nofollow\">";
 }
 
+/**
+ * convert_smilies() - {@internal Missing Short Description}}
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since 0.71
+ *
+ * @param unknown_type $text
+ * @return unknown
+ */
 function convert_smilies($text) {
 	global $wp_smiliessearch, $wp_smiliesreplace;
-    $output = '';
+	$output = '';
 	if ( get_option('use_smilies') && !empty($wp_smiliessearch) && !empty($wp_smiliesreplace) ) {
 		// HTML loop taken from texturize function, could possible be consolidated
 		$textarr = preg_split("/(<.*>)/U", $text, -1, PREG_SPLIT_DELIM_CAPTURE); // capture the tags as well as in between
@@ -697,7 +1023,16 @@
 	return $output;
 }
 
-
+/**
+ * is_email() - {@internal Missing Short Description}}
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since 0.71
+ *
+ * @param unknown_type $user_email
+ * @return unknown
+ */
 function is_email($user_email) {
 	$chars = "/^([a-z0-9+_]|\\-|\\.)+@(([a-z0-9_]|\\-)+\\.)+[a-z]{2,6}\$/i";
 	if (strpos($user_email, '@') !== false && strpos($user_email, '.') !== false) {
@@ -711,80 +1046,160 @@
 	}
 }
 
-// used by wp-mail to handle charsets in email subjects
+/**
+ * wp_iso_descrambler() - {@internal Missing Short Description}}
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since 1.2.0
+ * @usedby wp_mail() handles charsets in email subjects
+ *
+ * @param unknown_type $string
+ * @return unknown
+ */
 function wp_iso_descrambler($string) {
-  /* this may only work with iso-8859-1, I'm afraid */
-  if (!preg_match('#\=\?(.+)\?Q\?(.+)\?\=#i', $string, $matches)) {
-    return $string;
-  } else {
-    $subject = str_replace('_', ' ', $matches[2]);
-    $subject = preg_replace('#\=([0-9a-f]{2})#ei', "chr(hexdec(strtolower('$1')))", $subject);
-    return $subject;
-  }
+	/* this may only work with iso-8859-1, I'm afraid */
+	if (!preg_match('#\=\?(.+)\?Q\?(.+)\?\=#i', $string, $matches)) {
+		return $string;
+	} else {
+		$subject = str_replace('_', ' ', $matches[2]);
+		$subject = preg_replace('#\=([0-9a-f]{2})#ei', "chr(hexdec(strtolower('$1')))", $subject);
+		return $subject;
+	}
 }
 
-
-// give it a date, it will give you the same date as GMT
+/**
+ * get_gmt_from_date() - Give it a date, it will give you the same date as GMT
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since 1.2.0
+ *
+ * @param unknown_type $string
+ * @return unknown
+ */
 function get_gmt_from_date($string) {
-  // note: this only substracts $time_difference from the given date
-  preg_match('#([0-9]{1,4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})#', $string, $matches);
-  $string_time = gmmktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
-  $string_gmt = gmdate('Y-m-d H:i:s', $string_time - get_option('gmt_offset') * 3600);
-  return $string_gmt;
+	// note: this only substracts $time_difference from the given date
+	preg_match('#([0-9]{1,4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})#', $string, $matches);
+	$string_time = gmmktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
+	$string_gmt = gmdate('Y-m-d H:i:s', $string_time - get_option('gmt_offset') * 3600);
+	return $string_gmt;
 }
 
-// give it a GMT date, it will give you the same date with $time_difference added
+/**
+ * get_date_from_gmt() - Give it a GMT date, it will give you the same date with $time_difference added
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since 1.2.0
+ *
+ * @param unknown_type $string
+ * @return unknown
+ */
 function get_date_from_gmt($string) {
-  // note: this only adds $time_difference to the given date
-  preg_match('#([0-9]{1,4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})#', $string, $matches);
-  $string_time = gmmktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
-  $string_localtime = gmdate('Y-m-d H:i:s', $string_time + get_option('gmt_offset')*3600);
-  return $string_localtime;
+	// note: this only adds $time_difference to the given date
+	preg_match('#([0-9]{1,4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})#', $string, $matches);
+	$string_time = gmmktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
+	$string_localtime = gmdate('Y-m-d H:i:s', $string_time + get_option('gmt_offset')*3600);
+	return $string_localtime;
 }
 
-// computes an offset in seconds from an iso8601 timezone
+/**
+ * iso8601_timezone_to_offset() - Computes an offset in seconds from an iso8601 timezone
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since 1.5.0
+ *
+ * @param unknown_type $timezone
+ * @return unknown
+ */
 function iso8601_timezone_to_offset($timezone) {
-  // $timezone is either 'Z' or '[+|-]hhmm'
-  if ($timezone == 'Z') {
-    $offset = 0;
-  } else {
-    $sign    = (substr($timezone, 0, 1) == '+') ? 1 : -1;
-    $hours   = intval(substr($timezone, 1, 2));
-    $minutes = intval(substr($timezone, 3, 4)) / 60;
-    $offset  = $sign * 3600 * ($hours + $minutes);
-  }
-  return $offset;
+	// $timezone is either 'Z' or '[+|-]hhmm'
+	if ($timezone == 'Z') {
+		$offset = 0;
+	} else {
+		$sign    = (substr($timezone, 0, 1) == '+') ? 1 : -1;
+		$hours   = intval(substr($timezone, 1, 2));
+		$minutes = intval(substr($timezone, 3, 4)) / 60;
+		$offset  = $sign * 3600 * ($hours + $minutes);
+	}
+	return $offset;
 }
 
-// converts an iso8601 date to MySQL DateTime format used by post_date[_gmt]
+/**
+ * iso8601_to_datetime() - Converts an iso8601 date to MySQL DateTime format used by post_date[_gmt]
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since 1.5.0
+ *
+ * @param unknown_type $date_string
+ * @param unknown_type $timezone
+ * @return unknown
+ */
 function iso8601_to_datetime($date_string, $timezone = USER) {
-  if ($timezone == GMT) {
-    preg_match('#([0-9]{4})([0-9]{2})([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(Z|[\+|\-][0-9]{2,4}){0,1}#', $date_string, $date_bits);
-    if (!empty($date_bits[7])) { // we have a timezone, so let's compute an offset
-      $offset = iso8601_timezone_to_offset($date_bits[7]);
-    } else { // we don't have a timezone, so we assume user local timezone (not server's!)
-      $offset = 3600 * get_option('gmt_offset');
-    }
-    $timestamp = gmmktime($date_bits[4], $date_bits[5], $date_bits[6], $date_bits[2], $date_bits[3], $date_bits[1]);
-    $timestamp -= $offset;
-    return gmdate('Y-m-d H:i:s', $timestamp);
-  } elseif ($timezone == USER) {
-    return preg_replace('#([0-9]{4})([0-9]{2})([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(Z|[\+|\-][0-9]{2,4}){0,1}#', '$1-$2-$3 $4:$5:$6', $date_string);
-  }
+	if ($timezone == GMT) {
+
+		preg_match('#([0-9]{4})([0-9]{2})([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(Z|[\+|\-][0-9]{2,4}){0,1}#', $date_string, $date_bits);
+
+		if (!empty($date_bits[7])) { // we have a timezone, so let's compute an offset
+			$offset = iso8601_timezone_to_offset($date_bits[7]);
+		} else { // we don't have a timezone, so we assume user local timezone (not server's!)
+			$offset = 3600 * get_option('gmt_offset');
+		}
+
+		$timestamp = gmmktime($date_bits[4], $date_bits[5], $date_bits[6], $date_bits[2], $date_bits[3], $date_bits[1]);
+		$timestamp -= $offset;
+
+		return gmdate('Y-m-d H:i:s', $timestamp);
+
+	} else if ($timezone == USER) {
+		return preg_replace('#([0-9]{4})([0-9]{2})([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(Z|[\+|\-][0-9]{2,4}){0,1}#', '$1-$2-$3 $4:$5:$6', $date_string);
+	}
 }
 
+/**
+ * popuplinks() - Adds a element attributes to open links in new windows
+ *
+ * Comment text in popup windows should be filtered through this. Right
+ * now it's a moderately dumb function, ideally it would detect whether
+ * a target or rel attribute was already there and adjust its actions
+ * accordingly.
+ *
+ * @since 0.71
+ *
+ * @param string $text Content to replace links to open in a new window
+ * @return string Content that has filtered links
+ */
 function popuplinks($text) {
-	// Comment text in popup windows should be filtered through this.
-	// Right now it's a moderately dumb function, ideally it would detect whether
-	// a target or rel attribute was already there and adjust its actions accordingly.
 	$text = preg_replace('/<a (.+?)>/i', "<a $1 target='_blank' rel='external'>", $text);
 	return $text;
 }
 
+/**
+ * sanitize_email() - Strips out all characters that are not allowable in an email
+ *
+ * @since 1.5.0
+ *
+ * @param string $email Email address to filter
+ * @return string Filtered email address
+ */
 function sanitize_email($email) {
 	return preg_replace('/[^a-z0-9+_.@-]/i', '', $email);
 }
 
+/**
+ * human_time_diff() - {@internal Missing Short Description}}
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since 1.5.0
+ *
+ * @param unknown_type $from
+ * @param unknown_type $to
+ * @return unknown
+ */
 function human_time_diff( $from, $to = '' ) {
 	if ( empty($to) )
 		$to = time();
@@ -811,6 +1226,16 @@
 	return $since;
 }
 
+/**
+ * wp_trim_excerpt() - {@internal Missing Short Description}}
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since 1.5.0
+ *
+ * @param unknown_type $text
+ * @return unknown
+ */
 function wp_trim_excerpt($text) { // Fakes an excerpt if needed
 	if ( '' == $text ) {
 		$text = get_the_content('');
@@ -828,6 +1253,16 @@
 	return $text;
 }
 
+/**
+ * ent2ncr() - {@internal Missing Short Description}}
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since 1.5.1
+ *
+ * @param unknown_type $text
+ * @return unknown
+ */
 function ent2ncr($text) {
 	$to_ncr = array(
 		'&quot;' => '&#34;',
@@ -1092,6 +1527,16 @@
 	return str_replace( array_keys($to_ncr), array_values($to_ncr), $text );
 }
 
+/**
+ * wp_richedit_pre() - {@internal Missing Short Description}}
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since 2.0.0
+ *
+ * @param unknown_type $text
+ * @return unknown
+ */
 function wp_richedit_pre($text) {
 	// Filtering a blank results in an annoying <br />\n
 	if ( empty($text) ) return apply_filters('richedit_pre', '');
@@ -1107,6 +1552,18 @@
 	return apply_filters('richedit_pre', $output);
 }
 
+/**
+ * clean_url() - {@internal Missing Short Description}}
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since 1.2.0
+ *
+ * @param unknown_type $url
+ * @param unknown_type $protocols
+ * @param unknown_type $context
+ * @return unknown
+ */
 function clean_url( $url, $protocols = null, $context = 'display' ) {
 	$original_url = $url;
 
@@ -1118,7 +1575,7 @@
 	/* If the URL doesn't appear to contain a scheme, we
 	 * presume it needs http:// appended (unless a relative
 	 * link starting with / or a php file).
-	*/
+	 */
 	if ( strpos($url, ':') === false &&
 		substr( $url, 0, 1 ) != '/' && !preg_match('/^[a-z0-9-]+?\.php/i', $url) )
 		$url = 'http://' . $url;
@@ -1135,19 +1592,49 @@
 	return apply_filters('clean_url', $url, $original_url, $context);
 }
 
+/**
+ * sanitize_url() - {@internal Missing Short Description}}
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since 2.3.1
+ *
+ * @param unknown_type $url
+ * @param unknown_type $protocols
+ * @return unknown
+ */
 function sanitize_url( $url, $protocols = null ) {
-	return clean_url( $url, $protocols, 'db');
+	return clean_url( $url, $protocols, 'db' );
 }
 
-// Borrowed from the PHP Manual user notes. Convert entities, while
-// preserving already-encoded entities:
+/**
+ * htmlentities2() - Convert entities, while preserving already-encoded entities
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @link http://www.php.net/htmlentities Borrowed from the PHP Manual user notes.
+ *
+ * @since 1.2.2
+ *
+ * @param unknown_type $myHTML
+ * @return unknown
+ */
 function htmlentities2($myHTML) {
-	$translation_table=get_html_translation_table (HTML_ENTITIES,ENT_QUOTES);
+	$translation_table = get_html_translation_table( HTML_ENTITIES, ENT_QUOTES );
 	$translation_table[chr(38)] = '&';
-	return preg_replace("/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,3};)/","&amp;" , strtr($myHTML, $translation_table));
+	return preg_replace( "/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,3};)/", "&amp;", strtr($myHTML, $translation_table) );
 }
 
-// Escape single quotes, specialchar double quotes, and fix line endings.
+/**
+ * js_escape() - Escape single quotes, specialchar double quotes, and fix line endings
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since 2.0.4
+ *
+ * @param string $text
+ * @return unknown
+ */
 function js_escape($text) {
 	$safe_text = wp_specialchars($text, 'double');
 	$safe_text = preg_replace('/&#(x)?0*(?(1)27|39);?/i', "'", stripslashes($safe_text));
@@ -1155,17 +1642,48 @@
 	return apply_filters('js_escape', $safe_text, $text);
 }
 
-// Escaping for HTML attributes
+/**
+ * attribute_escape() - Escaping for HTML attributes
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since 2.0.6
+ *
+ * @param unknown_type $text
+ * @return unknown
+ */
 function attribute_escape($text) {
 	$safe_text = wp_specialchars($text, true);
 	return apply_filters('attribute_escape', $safe_text, $text);
 }
 
+/**
+ * wp_make_link_relative() - {@internal Missing Short Description}}
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since 2.1.0
+ *
+ * @param unknown_type $link
+ * @return unknown
+ */
 function wp_make_link_relative( $link ) {
-	return preg_replace('|https?://[^/]+(/.*)|i', '$1', $link );
+	return preg_replace( '|https?://[^/]+(/.*)|i', '$1', $link );
 }
 
-function sanitize_option($option, $value) { // Remember to call stripslashes!
+/**
+ * sanitize_option() - {@internal Missing Short Description}}
+ *
+ * {@internal Missing Long Description}}
+ * Remember to call stripslashes!
+ *
+ * @since 2.0.5
+ *
+ * @param unknown_type $option
+ * @param unknown_type $value
+ * @return unknown
+ */
+function sanitize_option($option, $value) {
 
 	switch ($option) {
 		case 'admin_email':
@@ -1239,6 +1757,17 @@
 	return $value;
 }
 
+/**
+ * wp_parse_str() - {@internal Missing Short Description}}
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since 2.2.1
+ * @uses apply_filters() 
+ *
+ * @param string $string
+ * @param array $array
+ */
 function wp_parse_str( $string, &$array ) {
 	parse_str( $string, $array );
 	if ( get_magic_quotes_gpc() )
@@ -1246,15 +1775,35 @@
 	$array = apply_filters( 'wp_parse_str', $array );
 }
 
-// Convert lone less than signs.  KSES already converts lone greater than signs.
+/**
+ * wp_pre_kses_less_than() - Convert lone less than signs.
+ *
+ * KSES already converts lone greater than signs.
+ * {@internal Missing Long Description}}
+ *
+ * @since 2.3.0
+ *
+ * @param string $text
+ * @return unknown
+ */
 function wp_pre_kses_less_than( $text ) {
 	return preg_replace_callback('%<[^>]*?((?=<)|>|$)%', 'wp_pre_kses_less_than_callback', $text);
 }
 
+/**
+ * wp_pre_kses_less_than_callback() - {@internal Missing Short Description}}
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since 2.3.0
+ *
+ * @param unknown_type $matches
+ * @return unknown
+ */
 function wp_pre_kses_less_than_callback( $matches ) {
 	if ( false === strpos($matches[0], '>') )
 		return wp_specialchars($matches[0]);
 	return $matches[0];
 }
 
-?>
+?>
\ No newline at end of file
