<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1452,18 +1452,20 @@ function wp_iso_descrambler($string) {
  * Returns a date in the GMT equivalent.
  *
  * Requires and returns a date in the Y-m-d H:i:s format. Simply subtracts the
- * value of the 'gmt_offset' option.
+ * value of the 'gmt_offset' option. Return format can be overridden using the
+ * $format parameter
  *
  * @since 1.2.0
  *
  * @uses get_option() to retrieve the the value of 'gmt_offset'.
  * @param string $string The date to be converted.
+ * @param string $format The format string for the returned date (default is Y-m-d H:i:s)
  * @return string GMT version of the date provided.
  */
-function get_gmt_from_date($string) {
+function get_gmt_from_date($string, $format = 'Y-m-d H:i:s') {
 	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);
+	$string_gmt = gmdate($format, $string_time - get_option('gmt_offset') * 3600);
 	return $string_gmt;
 }
 
@@ -1471,17 +1473,18 @@ function get_gmt_from_date($string) {
  * Converts a GMT date into the correct format for the blog.
  *
  * Requires and returns in the Y-m-d H:i:s format. Simply adds the value of
- * gmt_offset.
+ * gmt_offset.Return format can be overridden using the $format parameter
  *
  * @since 1.2.0
  *
  * @param string $string The date to be converted.
+ * @param string $format The format string for the returned date (default is Y-m-d H:i:s)
  * @return string Formatted date relative to the GMT offset.
  */
-function get_date_from_gmt($string) {
+function get_date_from_gmt($string, $format = 'Y-m-d H:i:s') {
 	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);
+	$string_localtime = gmdate($format, $string_time + get_option('gmt_offset')*3600);
 	return $string_localtime;
 }
 </diff>
      <filename>wp-includes/formatting.php</filename>
    </modified>
    <modified>
      <diff>@@ -526,6 +526,11 @@ class wp_xmlrpc_server extends IXR_Server {
 			$page_date = mysql2date(&quot;Ymd\TH:i:s&quot;, $page-&gt;post_date, false);
 			$page_date_gmt = mysql2date(&quot;Ymd\TH:i:s&quot;, $page-&gt;post_date_gmt, false);
 
+			// For drafts use the GMT version of the date
+			if ( $page-&gt;post_status == 'draft' ) {
+				$page_date_gmt = get_gmt_from_date( mysql2date( 'Y-m-d H:i:s', $page-&gt;post_date ), 'Ymd\TH:i:s' );
+			}
+
 			// Pull the categories info together.
 			$categories = array();
 			foreach(wp_get_post_categories($page-&gt;ID) as $cat_id) {
@@ -790,7 +795,8 @@ class wp_xmlrpc_server extends IXR_Server {
 				post_title page_title,
 				post_parent page_parent_id,
 				post_date_gmt,
-				post_date
+				post_date,
+				post_status
 			FROM {$wpdb-&gt;posts}
 			WHERE post_type = 'page'
 			ORDER BY ID
@@ -805,8 +811,15 @@ class wp_xmlrpc_server extends IXR_Server {
 			$page_list[$i]-&gt;dateCreated = new IXR_Date($post_date);
 			$page_list[$i]-&gt;date_created_gmt = new IXR_Date($post_date_gmt);
 
+			// For drafts use the GMT version of the date
+			if ( $page_list[$i]-&gt;post_status == 'draft' ) {
+				$page_list[$i]-&gt;date_created_gmt = get_gmt_from_date( mysql2date( 'Y-m-d H:i:s', $page_list[$i]-&gt;post_date ), 'Ymd\TH:i:s' );
+				$page_list[$i]-&gt;date_created_gmt = new IXR_Date( $page_list[$i]-&gt;date_created_gmt );
+			}
+
 			unset($page_list[$i]-&gt;post_date_gmt);
 			unset($page_list[$i]-&gt;post_date);
+			unset($page_list[$i]-&gt;post_status);
 		}
 
 		return($page_list);
@@ -2576,9 +2589,7 @@ class wp_xmlrpc_server extends IXR_Server {
 
 			// 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'] ) );
-				$post_date_gmt = preg_replace( '|\-|', '', $post_date_gmt );
-				$post_date_gmt = preg_replace( '| |', 'T', $post_date_gmt );
+				$post_date_gmt = get_gmt_from_date( mysql2date( 'Y-m-d H:i:s', $postdata['post_date'] ), 'Ymd\TH:i:s' );
 			}
 
 			$categories = array();
@@ -2697,6 +2708,11 @@ class wp_xmlrpc_server extends IXR_Server {
 			$post_date = mysql2date('Ymd\TH:i:s', $entry['post_date'], false);
 			$post_date_gmt = mysql2date('Ymd\TH:i:s', $entry['post_date_gmt'], false);
 
+			// 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' );
+			}
+
 			$categories = array();
 			$catids = wp_get_post_categories($entry['ID']);
 			foreach($catids as $catid) {
@@ -2932,6 +2948,11 @@ class wp_xmlrpc_server extends IXR_Server {
 			$post_date = mysql2date('Ymd\TH:i:s', $entry['post_date'], false);
 			$post_date_gmt = mysql2date('Ymd\TH:i:s', $entry['post_date_gmt'], false);
 
+			// 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' =&gt; new IXR_Date($post_date),
 				'userid' =&gt; $entry['post_author'],</diff>
      <filename>xmlrpc.php</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>3958df020f2cb3b394eac247e989226bfb734af4</id>
    </parent>
  </parents>
  <author>
    <name>westi</name>
    <email>westi@1a063a9b-81f0-0310-95a4-ce76da25c4cd</email>
  </author>
  <url>http://github.com/blowery/wordpress/commit/15aee919f7a1ee8611076c1102e5fbbf4933ba92</url>
  <id>15aee919f7a1ee8611076c1102e5fbbf4933ba92</id>
  <committed-date>2009-08-20T00:06:08-07:00</committed-date>
  <authored-date>2009-08-20T00:06:08-07:00</authored-date>
  <message>Ensure that drafts viewed over XMLRPC have a correct gmt date set. Fixes #10244 for 2.8 branch props josephscott.

git-svn-id: http://svn.automattic.com/wordpress/branches/2.8@11847 1a063a9b-81f0-0310-95a4-ce76da25c4cd</message>
  <tree>fcd0e22ed0f9789eab313689d9d72375c5d63ff3</tree>
  <committer>
    <name>westi</name>
    <email>westi@1a063a9b-81f0-0310-95a4-ce76da25c4cd</email>
  </committer>
</commit>
