Index: wp-includes/class-wp-xmlrpc-server.php
===================================================================
--- wp-includes/class-wp-xmlrpc-server.php	(revision 20333)
+++ wp-includes/class-wp-xmlrpc-server.php	(working copy)
@@ -499,7 +499,7 @@
 	 * Prepares taxonomy data for return in an XML-RPC object.
 	 *
 	 * @access protected
-	.*
+	 *
 	 * @param array|object $taxonomy The unprepared taxonomy data
 	 * @return array The prepared taxonomy data
 	 */
@@ -515,7 +515,7 @@
 	 * Prepares term data for return in an XML-RPC object.
 	 *
 	 * @access protected
-	.*
+	 *
 	 * @param array|object $term The unprepared term data
 	 * @return array The prepared term data
 	 */
@@ -548,10 +548,37 @@
 		if ( $date === '0000-00-00 00:00:00' ) {
 			return new IXR_Date( '00000000T00:00:00Z' );
 		}
-		return new IXR_Date( mysql2date( 'Ymd\TH:i:s', $date, false ) );
+		return new IXR_Date( $this->_convert_mysql2date( $date ) );
 	}
 
 	/**
+	 * Convert a WordPress gmt date string to an IXR_Date object.
+	 *
+	 * @access protected
+	 *
+	 * @param $date
+	 * @return IXR_Date
+	 */
+	protected function _convert_date_gmt( $date_gmt, $date ) {
+		if ( $date !== '0000-00-00 00:00:00' && $date_gmt === '0000-00-00 00:00:00' ) {
+			return new IXR_Date( get_gmt_from_date( $this->_convert_mysql2date( $date, 'Y-m-d H:i:s', $date ), 'Ymd\TH:i:s' ) );
+		}
+		return $this-> _convert_date( $date_gmt );
+	}
+
+	/**
+	 * Convert a MySQL date to 
+	 *
+	 * @access protected
+	 *
+	 * @param $date
+	 * @return IXR_Date
+	 */
+	protected function _convert_mysql2date( $date, $format = 'Ymd\TH:i:s' ) {
+		return mysql2date( $format, $date, false );
+	}
+
+	/**
 	 * Prepares post data for return in an XML-RPC object.
 	 *
 	 * @access protected
@@ -568,9 +595,9 @@
 		$post_fields = array(
 			'post_title'        => $post['post_title'],
 			'post_date'         => $this->_convert_date( $post['post_date'] ),
-			'post_date_gmt'     => $this->_convert_date( $post['post_date_gmt'] ),
+			'post_date_gmt'     => $this->_convert_date_gmt( $post['post_date_gmt'], $post['post_date'] ),
 			'post_modified'     => $this->_convert_date( $post['post_modified'] ),
-			'post_modified_gmt' => $this->_convert_date( $post['post_modified_gmt'] ),
+			'post_modified_gmt' => $this->_convert_date_gmt( $post['post_modified_gmt'], $post['post_modified'] ),
 			'post_status'       => $post['post_status'],
 			'post_type'         => $post['post_type'],
 			'post_name'         => $post['post_name'],
@@ -1714,13 +1741,9 @@
 			$allow_pings = pings_open($page->ID) ? 1 : 0;
 
 			// Format page date.
-			$page_date = mysql2date('Ymd\TH:i:s', $page->post_date, false);
-			$page_date_gmt = mysql2date('Ymd\TH:i:s', $page->post_date_gmt, false);
+			$page_date = $this->_convert_date( $page->post_date );
+			$page_date_gmt = $this->_convert_date_gmt( $page->post_date_gmt, $page->post_date );
 
-			// For drafts use the GMT version of the date
-			if ( $page->post_status == 'draft' )
-				$page_date_gmt = get_gmt_from_date( mysql2date( 'Y-m-d H:i:s', $page->post_date ), 'Ymd\TH:i:s' );
-
 			// Pull the categories info together.
 			$categories = array();
 			foreach ( wp_get_post_categories($page->ID) as $cat_id ) {
@@ -1735,7 +1758,7 @@
 				$page_template = 'default';
 
 			$page_struct = array(
-				'dateCreated'			=> new IXR_Date($page_date),
+				'dateCreated'			=> $page_date,
 				'userid'				=> $page->post_author,
 				'page_id'				=> $page->ID,
 				'page_status'			=> $page->post_status,
@@ -1756,7 +1779,7 @@
 				'wp_page_order'			=> $page->menu_order,
 				'wp_author_id'			=> (string) $author->ID,
 				'wp_author_display_name'	=> $author->display_name,
-				'date_created_gmt'		=> new IXR_Date($page_date_gmt),
+				'date_created_gmt'		=> $page_date_gmt,
 				'custom_fields'			=> $this->get_custom_fields($page_id),
 				'wp_page_template'		=> $page_template
 			);
@@ -1975,18 +1998,9 @@
 		// The date needs to be formatted properly.
 		$num_pages = count($page_list);
 		for ( $i = 0; $i < $num_pages; $i++ ) {
-			$post_date = mysql2date('Ymd\TH:i:s', $page_list[$i]->post_date, false);
-			$post_date_gmt = mysql2date('Ymd\TH:i:s', $page_list[$i]->post_date_gmt, false);
+			$page_list[$i]->dateCreated = $this->_convert_date(  $page_list[$i]->post_date );
+			$page_list[$i]->date_created_gmt = $this->_convert_date_gmt( $page_list[$i]->post_date_gmt, $page_list[$i]->post_date );
 
-			$page_list[$i]->dateCreated = new IXR_Date($post_date);
-			$page_list[$i]->date_created_gmt = new IXR_Date($post_date_gmt);
-
-			// For drafts use the GMT version of the date
-			if ( $page_list[$i]->post_status == 'draft' ) {
-				$page_list[$i]->date_created_gmt = get_gmt_from_date( mysql2date( 'Y-m-d H:i:s', $page_list[$i]->post_date ), 'Ymd\TH:i:s' );
-				$page_list[$i]->date_created_gmt = new IXR_Date( $page_list[$i]->date_created_gmt );
-			}
-
 			unset($page_list[$i]->post_date_gmt);
 			unset($page_list[$i]->post_date);
 			unset($page_list[$i]->post_status);
@@ -2230,8 +2244,8 @@
 			return new IXR_Error( 404, __( 'Invalid comment ID.' ) );
 
 		// Format page date.
-		$comment_date = mysql2date('Ymd\TH:i:s', $comment->comment_date, false);
-		$comment_date_gmt = mysql2date('Ymd\TH:i:s', $comment->comment_date_gmt, false);
+		$comment_date = $this->_convert_date( $comment->comment_date );
+		$comment_date_gmt = $this->_convert_date_gmt( $comment->comment_date_gmt, $comment->comment_date );
 
 		if ( '0' == $comment->comment_approved )
 			$comment_status = 'hold';
@@ -2245,7 +2259,7 @@
 		$link = get_comment_link($comment);
 
 		$comment_struct = array(
-			'date_created_gmt'		=> new IXR_Date($comment_date_gmt),
+			'date_created_gmt'		=> $comment_date_gmt,
 			'user_id'				=> $comment->user_id,
 			'comment_id'			=> $comment->comment_ID,
 			'parent'				=> $comment->comment_parent,
@@ -2824,14 +2838,14 @@
 			return new IXR_Error( 404, __( 'Invalid attachment ID.' ) );
 
 		// Format page date.
-		$attachment_date = mysql2date('Ymd\TH:i:s', $attachment->post_date, false);
-		$attachment_date_gmt = mysql2date('Ymd\TH:i:s', $attachment->post_date_gmt, false);
+		$attachment_date = $this->_convert_date( $attachment->post_date );
+		$attachment_date_gmt = $this->_convert_date_gmt( $attachment->post_date_gmt, $attachment->post_date );
 
 		$link = wp_get_attachment_url($attachment->ID);
 		$thumbnail_link = wp_get_attachment_thumb_url($attachment->ID);
 
 		$attachment_struct = array(
-			'date_created_gmt'		=> new IXR_Date($attachment_date_gmt),
+			'date_created_gmt'		=> $attachment_date_gmt,
 			'parent'				=> $attachment->post_parent,
 			'link'					=> $link,
 			'thumbnail'				=> $thumbnail_link,
@@ -3182,7 +3196,7 @@
 
 		$struct = array(
 			'userid'    => $post_data['post_author'],
-			'dateCreated' => new IXR_Date(mysql2date('Ymd\TH:i:s', $post_data['post_date'], false)),
+			'dateCreated' => $this->_convert_date( $post_data['post_date'] ),
 			'content'     => $content,
 			'postid'  => (string) $post_data['ID']
 		);
@@ -3227,7 +3241,7 @@
 			if ( !current_user_can( 'edit_post', $entry['ID'] ) )
 				continue;
 
-			$post_date = mysql2date('Ymd\TH:i:s', $entry['post_date'], false);
+			$post_date  = $this->_convert_date( $entry['post_date'] );
 			$categories = implode(',', wp_get_post_categories($entry['ID']));
 
 			$content  = '<title>'.stripslashes($entry['post_title']).'</title>';
@@ -3236,7 +3250,7 @@
 
 			$struct[] = array(
 				'userid' => $entry['post_author'],
-				'dateCreated' => new IXR_Date($post_date),
+				'dateCreated' => $post_date,
 				'content' => $content,
 				'postid' => (string) $entry['ID'],
 			);
@@ -4120,17 +4134,11 @@
 		$postdata = wp_get_single_post($post_ID, ARRAY_A);
 
 		if ($postdata['post_date'] != '') {
-			$post_date = mysql2date('Ymd\TH:i:s', $postdata['post_date'], false);
-			$post_date_gmt = mysql2date('Ymd\TH:i:s', $postdata['post_date_gmt'], false);
-			$post_modified = mysql2date('Ymd\TH:i:s', $postdata['post_modified'], false);
-			$post_modified_gmt = mysql2date('Ymd\TH:i:s', $postdata['post_modified_gmt'], false);
+			$post_date = $this->_convert_date( $postdata['post_date'] );
+			$post_date_gmt = $this->_convert_date_gmt( $postdata['post_date_gmt'],  $postdata['post_date'] );
+			$post_modified = $this->_convert_date( $postdata['post_modified'] );
+			$post_modified_gmt = $this->_convert_date_gmt( $postdata['post_modified_gmt'], $postdata['post_modified'] );
 
-			// For drafts use the GMT version of the post date
-			if ( $postdata['post_status'] == 'draft' ) {
-				$post_date_gmt = get_gmt_from_date( mysql2date( 'Y-m-d H:i:s', $postdata['post_date'] ), 'Ymd\TH:i:s' );
-				$post_modified_gmt = get_gmt_from_date( mysql2date( 'Y-m-d H:i:s', $postdata['post_modified'] ), 'Ymd\TH:i:s' );
-			}
-
 			$categories = array();
 			$catids = wp_get_post_categories($post_ID);
 			foreach($catids as $catid)
@@ -4182,7 +4190,7 @@
 			}
 
 			$resp = array(
-				'dateCreated' => new IXR_Date($post_date),
+				'dateCreated' => $post_date,
 				'userid' => $postdata['post_author'],
 				'postid' => $postdata['ID'],
 				'description' => $post['main'],
@@ -4201,14 +4209,14 @@
 				'wp_slug' => $postdata['post_name'],
 				'wp_password' => $postdata['post_password'],
 				'wp_author_id' => (string) $author->ID,
-				'wp_author_display_name'	=> $author->display_name,
-				'date_created_gmt' => new IXR_Date($post_date_gmt),
+				'wp_author_display_name' => $author->display_name,
+				'date_created_gmt' => $post_date_gmt,
 				'post_status' => $postdata['post_status'],
 				'custom_fields' => $this->get_custom_fields($post_ID),
 				'wp_post_format' => $post_format,
 				'sticky' => $sticky,
-				'date_modified' => new IXR_Date( $post_modified ),
-				'date_modified_gmt' => new IXR_Date( $post_modified_gmt )
+				'date_modified' => $post_modified,
+				'date_modified_gmt' => $post_modified_gmt
 			);
 
 			if ( !empty($enclosure) ) $resp['enclosure'] = $enclosure;
@@ -4256,17 +4264,11 @@
 			if ( !current_user_can( 'edit_post', $entry['ID'] ) )
 				continue;
 
-			$post_date = mysql2date('Ymd\TH:i:s', $entry['post_date'], false);
-			$post_date_gmt = mysql2date('Ymd\TH:i:s', $entry['post_date_gmt'], false);
-			$post_modified = mysql2date('Ymd\TH:i:s', $entry['post_modified'], false);
-			$post_modified_gmt = mysql2date('Ymd\TH:i:s', $entry['post_modified_gmt'], false);
+			$post_date = $this->_convert_date( $entry['post_date'] );
+			$post_date_gmt = $this->_convert_date_gmt( $entry['post_date_gmt'], $entry['post_date'] );
+			$post_modified = $this->_convert_date( $entry['post_modified'] );
+			$post_modified_gmt = $this->_convert_date_gmt( $entry['post_modified_gmt'], $entry['post_modified'] );
 
-			// For drafts use the GMT version of the date
-			if ( $entry['post_status'] == 'draft' ) {
-				$post_date_gmt = get_gmt_from_date( mysql2date( 'Y-m-d H:i:s', $entry['post_date'] ), 'Ymd\TH:i:s' );
-				$post_modified_gmt = get_gmt_from_date( mysql2date( 'Y-m-d H:i:s', $entry['post_modified'] ), 'Ymd\TH:i:s' );
-			}
-
 			$categories = array();
 			$catids = wp_get_post_categories($entry['ID']);
 			foreach( $catids as $catid )
@@ -4302,7 +4304,7 @@
 				$post_format = 'standard';
 
 			$struct[] = array(
-				'dateCreated' => new IXR_Date($post_date),
+				'dateCreated' => $post_date,
 				'userid' => $entry['post_author'],
 				'postid' => (string) $entry['ID'],
 				'description' => $post['main'],
@@ -4322,12 +4324,12 @@
 				'wp_password' => $entry['post_password'],
 				'wp_author_id' => (string) $author->ID,
 				'wp_author_display_name' => $author->display_name,
-				'date_created_gmt' => new IXR_Date($post_date_gmt),
+				'date_created_gmt' => $post_date_gmt,
 				'post_status' => $entry['post_status'],
 				'custom_fields' => $this->get_custom_fields($entry['ID']),
 				'wp_post_format' => $post_format,
-				'date_modified' => new IXR_Date( $post_modified ),
-				'date_modified_gmt' => new IXR_Date( $post_modified_gmt )
+				'date_modified' => $post_modified,
+				'date_modified_gmt' => $post_modified_gmt
 			);
 
 			$entry_index = count( $struct ) - 1;
@@ -4513,20 +4515,16 @@
 			if ( !current_user_can( 'edit_post', $entry['ID'] ) )
 				continue;
 
-			$post_date = mysql2date('Ymd\TH:i:s', $entry['post_date'], false);
-			$post_date_gmt = mysql2date('Ymd\TH:i:s', $entry['post_date_gmt'], false);
+			$post_date = $this->_convert_date( $entry['post_date'] );
+			$post_date_gmt = $this->_convert_date_gmt( $entry['post_date_gmt'], $entry['post_date'] );
 
-			// For drafts use the GMT version of the date
-			if ( $entry['post_status'] == 'draft' )
-				$post_date_gmt = get_gmt_from_date( mysql2date( 'Y-m-d H:i:s', $entry['post_date'] ), 'Ymd\TH:i:s' );
-
 			$struct[] = array(
-				'dateCreated' => new IXR_Date($post_date),
+				'dateCreated' => $post_date,
 				'userid' => $entry['post_author'],
 				'postid' => (string) $entry['ID'],
 				'title' => $entry['post_title'],
 				'post_status' => $entry['post_status'],
-				'date_created_gmt' => new IXR_Date($post_date_gmt)
+				'date_created_gmt' => $post_date_gmt
 			);
 
 		}
