Index: wp-includes/class-wp-xmlrpc-server.php
===================================================================
--- wp-includes/class-wp-xmlrpc-server.php	(revision 20159)
+++ wp-includes/class-wp-xmlrpc-server.php	(working copy)
@@ -492,7 +492,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
 	 */
@@ -508,7 +508,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
 	 */
@@ -537,14 +537,29 @@
 	 * @param $date
 	 * @return IXR_Date
 	 */
-	protected function _convert_date( $date ) {
+	protected function _convert_date( $date, $format = 'Ymd\TH:i:s' ) {
 		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( mysql2date( $format, $date, false ) );
 	}
 
 	/**
+	 * Convert a WordPress gmt date string to an IXR_Date object.
+	 *
+	 * @access protected
+	 *
+	 * @param $date
+	 * @return IXR_Date
+	 */
+	protected function _convert_date_gmt( $date, $format = 'Ymd\TH:i:s' ) {
+		if ( $date === '0000-00-00 00:00:00' ) {
+			return new IXR_Date( '00000000T00:00:00Z' );
+		}
+		return new IXR_Date( get_gmt_from_date( mysql2date( $format, $date, false ) ) );
+	}
+
+	/**
 	 * Prepares post data for return in an XML-RPC object.
 	 *
 	 * @access protected
@@ -1633,12 +1648,12 @@
 			$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( $page->post_date_gmt );
 
 			// 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' );
+				$page_date_gmt = $this->_convert_date_gmt( $page->post_date );
 
 			// Pull the categories info together.
 			$categories = array();
@@ -1654,7 +1669,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,
@@ -1675,7 +1690,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
 			);
@@ -1894,16 +1909,12 @@
 		// 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( $page_list[$i]->post_date_gmt );
 
-			$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 );
+				$page_list[$i]->date_created_gmt = $this->_convert_date_gmt( $page_list[$i]->post_date );
 			}
 
 			unset($page_list[$i]->post_date_gmt);
@@ -2149,8 +2160,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( $comment->comment_date_gmt );
 
 		if ( '0' == $comment->comment_approved )
 			$comment_status = 'hold';
@@ -2164,7 +2175,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,
@@ -2743,14 +2754,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( $attachment->post_date_gmt );
 
 		$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,
@@ -3005,7 +3016,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']
 		);
@@ -3050,7 +3061,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>';
@@ -3059,7 +3070,7 @@
 
 			$struct[] = array(
 				'userid' => $entry['post_author'],
-				'dateCreated' => new IXR_Date($post_date),
+				'dateCreated' => $post_date,
 				'content' => $content,
 				'postid' => (string) $entry['ID'],
 			);
@@ -3918,15 +3929,15 @@
 		$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( $postdata['post_date_gmt'] );
+			$post_modified = $this->_convert_date( $postdata['post_modified'] );
+			$post_modified_gmt = $this->_convert_date( $postdata['post_modified_gmt'] );
 
 			// 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' );
+				$post_date_gmt = $this->_convert_date_gmt( $postdata['post_date'] );
+				$post_modified_gmt = $this->_convert_date_gmt( $postdata['post_modified'] );
 			}
 
 			$categories = array();
@@ -3980,7 +3991,7 @@
 			}
 
 			$resp = array(
-				'dateCreated' => new IXR_Date($post_date),
+				'dateCreated' => $post_date,
 				'userid' => $postdata['post_author'],
 				'postid' => $postdata['ID'],
 				'description' => $post['main'],
@@ -3999,14 +4010,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;
@@ -4051,15 +4062,15 @@
 			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( $entry['post_date_gmt'] );
+			$post_modified = $this->_convert_date( $entry['post_modified'] );
+			$post_modified_gmt = $this->_convert_date( $entry['post_modified_gmt'] );
 
 			// 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' );
+				$post_date_gmt = $this->_convert_date_gmt( $entry['post_date'] );
+				$post_modified_gmt = $this->_convert_date_gmt( $entry['post_modified'] );
 			}
 
 			$categories = array();
@@ -4097,7 +4108,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'],
@@ -4117,12 +4128,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
 			);
 
 		}
@@ -4299,20 +4310,20 @@
 			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( $entry['post_date_gmt'] );
 
 			// 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_date_gmt = $this->_convert_date_gmt( $entry['post_date'] );
 
 			$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
 			);
 
 		}
