Changeset 11847
- Timestamp:
- 08/20/2009 07:06:08 AM (14 years ago)
- Location:
- branches/2.8
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.8/wp-includes/formatting.php
r11635 r11847 1453 1453 * 1454 1454 * Requires and returns a date in the Y-m-d H:i:s format. Simply subtracts the 1455 * value of the 'gmt_offset' option. 1455 * value of the 'gmt_offset' option. Return format can be overridden using the 1456 * $format parameter 1456 1457 * 1457 1458 * @since 1.2.0 … … 1459 1460 * @uses get_option() to retrieve the the value of 'gmt_offset'. 1460 1461 * @param string $string The date to be converted. 1462 * @param string $format The format string for the returned date (default is Y-m-d H:i:s) 1461 1463 * @return string GMT version of the date provided. 1462 1464 */ 1463 function get_gmt_from_date($string ) {1465 function get_gmt_from_date($string, $format = 'Y-m-d H:i:s') { 1464 1466 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); 1465 1467 $string_time = gmmktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]); 1466 $string_gmt = gmdate( 'Y-m-d H:i:s', $string_time - get_option('gmt_offset') * 3600);1468 $string_gmt = gmdate($format, $string_time - get_option('gmt_offset') * 3600); 1467 1469 return $string_gmt; 1468 1470 } … … 1472 1474 * 1473 1475 * Requires and returns in the Y-m-d H:i:s format. Simply adds the value of 1474 * gmt_offset. 1476 * gmt_offset.Return format can be overridden using the $format parameter 1475 1477 * 1476 1478 * @since 1.2.0 1477 1479 * 1478 1480 * @param string $string The date to be converted. 1481 * @param string $format The format string for the returned date (default is Y-m-d H:i:s) 1479 1482 * @return string Formatted date relative to the GMT offset. 1480 1483 */ 1481 function get_date_from_gmt($string ) {1484 function get_date_from_gmt($string, $format = 'Y-m-d H:i:s') { 1482 1485 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); 1483 1486 $string_time = gmmktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]); 1484 $string_localtime = gmdate( 'Y-m-d H:i:s', $string_time + get_option('gmt_offset')*3600);1487 $string_localtime = gmdate($format, $string_time + get_option('gmt_offset')*3600); 1485 1488 return $string_localtime; 1486 1489 } -
branches/2.8/xmlrpc.php
r11687 r11847 527 527 $page_date_gmt = mysql2date("Ymd\TH:i:s", $page->post_date_gmt, false); 528 528 529 // For drafts use the GMT version of the date 530 if ( $page->post_status == 'draft' ) { 531 $page_date_gmt = get_gmt_from_date( mysql2date( 'Y-m-d H:i:s', $page->post_date ), 'Ymd\TH:i:s' ); 532 } 533 529 534 // Pull the categories info together. 530 535 $categories = array(); … … 791 796 post_parent page_parent_id, 792 797 post_date_gmt, 793 post_date 798 post_date, 799 post_status 794 800 FROM {$wpdb->posts} 795 801 WHERE post_type = 'page' … … 806 812 $page_list[$i]->date_created_gmt = new IXR_Date($post_date_gmt); 807 813 814 // For drafts use the GMT version of the date 815 if ( $page_list[$i]->post_status == 'draft' ) { 816 $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' ); 817 $page_list[$i]->date_created_gmt = new IXR_Date( $page_list[$i]->date_created_gmt ); 818 } 819 808 820 unset($page_list[$i]->post_date_gmt); 809 821 unset($page_list[$i]->post_date); 822 unset($page_list[$i]->post_status); 810 823 } 811 824 … … 2577 2590 // For drafts use the GMT version of the post date 2578 2591 if ( $postdata['post_status'] == 'draft' ) { 2579 $post_date_gmt = get_gmt_from_date( mysql2date( 'Y-m-d H:i:s', $postdata['post_date'] ) ); 2580 $post_date_gmt = preg_replace( '|\-|', '', $post_date_gmt ); 2581 $post_date_gmt = preg_replace( '| |', 'T', $post_date_gmt ); 2592 $post_date_gmt = get_gmt_from_date( mysql2date( 'Y-m-d H:i:s', $postdata['post_date'] ), 'Ymd\TH:i:s' ); 2582 2593 } 2583 2594 … … 2698 2709 $post_date_gmt = mysql2date('Ymd\TH:i:s', $entry['post_date_gmt'], false); 2699 2710 2711 // For drafts use the GMT version of the date 2712 if ( $entry['post_status'] == 'draft' ) { 2713 $post_date_gmt = get_gmt_from_date( mysql2date( 'Y-m-d H:i:s', $entry['post_date'] ), 'Ymd\TH:i:s' ); 2714 } 2715 2700 2716 $categories = array(); 2701 2717 $catids = wp_get_post_categories($entry['ID']); … … 2932 2948 $post_date = mysql2date('Ymd\TH:i:s', $entry['post_date'], false); 2933 2949 $post_date_gmt = mysql2date('Ymd\TH:i:s', $entry['post_date_gmt'], false); 2950 2951 // For drafts use the GMT version of the date 2952 if ( $entry['post_status'] == 'draft' ) { 2953 $post_date_gmt = get_gmt_from_date( mysql2date( 'Y-m-d H:i:s', $entry['post_date'] ), 'Ymd\TH:i:s' ); 2954 } 2934 2955 2935 2956 $struct[] = array(
Note: See TracChangeset
for help on using the changeset viewer.