Don't localize dates where not appropriate. Props Denis-de-Bernardy, hakre. fixes #9730

git-svn-id: http://svn.automattic.com/wordpress/trunk@11323 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2009-05-14 02:00:32 +00:00
parent b15d639afe
commit 1354d0660a
17 changed files with 66 additions and 62 deletions

View File

@ -131,7 +131,7 @@ foreach ($posts_columns as $column_name => $column_display_name ) {
} else {
$t_time = get_the_time(__('Y/m/d g:i:s A'));
$m_time = $post->post_date;
$time = get_post_time( 'G', true, $post );
$time = get_post_time( 'G', true, $post, false );
if ( ( abs($t_diff = time() - $time) ) < 86400 ) {
if ( $t_diff < 0 )
$h_time = sprintf( __('%s from now'), human_time_diff( $time ) );

View File

@ -41,7 +41,7 @@ if ( 0 == $post_ID ) {
$autosave = wp_get_post_autosave( $post_ID );
// Detect if there exists an autosave newer than the post and if that autosave is different than the post
if ( $autosave && mysql2date( 'U', $autosave->post_modified_gmt ) > mysql2date( 'U', $post->post_modified_gmt ) ) {
if ( $autosave && mysql2date( 'U', $autosave->post_modified_gmt, false ) > mysql2date( 'U', $post->post_modified_gmt, false ) ) {
foreach ( _wp_post_revision_fields() as $autosave_field => $_autosave_field ) {
if ( normalize_whitespace( $autosave->$autosave_field ) != normalize_whitespace( $post->$autosave_field ) ) {
$notice = sprintf( $notices[1], get_edit_post_link( $autosave->ID ) );

View File

@ -41,7 +41,7 @@ if ( 0 == $post_ID) {
$nonce_action = 'update-page_' . $post_ID;
$form_extra = "<input type='hidden' id='post_ID' name='post_ID' value='$post_ID' />";
$autosave = wp_get_post_autosave( $post_ID );
if ( $autosave && mysql2date( 'U', $autosave->post_modified_gmt ) > mysql2date( 'U', $post->post_modified_gmt ) )
if ( $autosave && mysql2date( 'U', $autosave->post_modified_gmt, false ) > mysql2date( 'U', $post->post_modified_gmt, false ) )
$notice = sprintf( $notices[1], get_edit_post_link( $autosave->ID ) );
}

View File

@ -1298,12 +1298,12 @@ function get_inline_data($post) {
<div class="comment_status">' . $post->comment_status . '</div>
<div class="ping_status">' . $post->ping_status . '</div>
<div class="_status">' . $post->post_status . '</div>
<div class="jj">' . mysql2date( 'd', $post->post_date ) . '</div>
<div class="mm">' . mysql2date( 'm', $post->post_date ) . '</div>
<div class="aa">' . mysql2date( 'Y', $post->post_date ) . '</div>
<div class="hh">' . mysql2date( 'H', $post->post_date ) . '</div>
<div class="mn">' . mysql2date( 'i', $post->post_date ) . '</div>
<div class="ss">' . mysql2date( 's', $post->post_date ) . '</div>
<div class="jj">' . mysql2date( 'd', $post->post_date, false ) . '</div>
<div class="mm">' . mysql2date( 'm', $post->post_date, false ) . '</div>
<div class="aa">' . mysql2date( 'Y', $post->post_date, false ) . '</div>
<div class="hh">' . mysql2date( 'H', $post->post_date, false ) . '</div>
<div class="mn">' . mysql2date( 'i', $post->post_date, false ) . '</div>
<div class="ss">' . mysql2date( 's', $post->post_date, false ) . '</div>
<div class="post_password">' . wp_specialchars($post->post_password, 1) . '</div>';
if( $post->post_type == 'page' )
@ -2532,12 +2532,12 @@ function touch_time( $edit = 1, $for_post = 1, $tab_index = 0, $multi = 0 ) {
$time_adj = time() + (get_option( 'gmt_offset' ) * 3600 );
$post_date = ($for_post) ? $post->post_date : $comment->comment_date;
$jj = ($edit) ? mysql2date( 'd', $post_date ) : gmdate( 'd', $time_adj );
$mm = ($edit) ? mysql2date( 'm', $post_date ) : gmdate( 'm', $time_adj );
$aa = ($edit) ? mysql2date( 'Y', $post_date ) : gmdate( 'Y', $time_adj );
$hh = ($edit) ? mysql2date( 'H', $post_date ) : gmdate( 'H', $time_adj );
$mn = ($edit) ? mysql2date( 'i', $post_date ) : gmdate( 'i', $time_adj );
$ss = ($edit) ? mysql2date( 's', $post_date ) : gmdate( 's', $time_adj );
$jj = ($edit) ? mysql2date( 'd', $post_date, false ) : gmdate( 'd', $time_adj );
$mm = ($edit) ? mysql2date( 'm', $post_date, false ) : gmdate( 'm', $time_adj );
$aa = ($edit) ? mysql2date( 'Y', $post_date, false ) : gmdate( 'Y', $time_adj );
$hh = ($edit) ? mysql2date( 'H', $post_date, false ) : gmdate( 'H', $time_adj );
$mn = ($edit) ? mysql2date( 'i', $post_date, false ) : gmdate( 'i', $time_adj );
$ss = ($edit) ? mysql2date( 's', $post_date, false ) : gmdate( 's', $time_adj );
$cur_jj = gmdate( 'd', $time_adj );
$cur_mm = gmdate( 'm', $time_adj );

View File

@ -681,7 +681,7 @@ function upgrade_210() {
$posts = $wpdb->get_results("SELECT ID, post_date FROM $wpdb->posts WHERE post_status ='future'");
if ( !empty($posts) )
foreach ( $posts as $post )
wp_schedule_single_event(mysql2date('U', $post->post_date), 'publish_future_post', array($post->ID));
wp_schedule_single_event(mysql2date('U', $post->post_date, false), 'publish_future_post', array($post->ID));
}
}

View File

@ -96,7 +96,7 @@ include('./admin-header.php');
</tr>
<tr>
<?php
if (!wp_timezone_supported()) : // no magic timezone support here
if ( !wp_timezone_supported() ) : // no magic timezone support here
?>
<th scope="row"><label for="gmt_offset"><?php _e('Timezone') ?> </label></th>
<td>
@ -124,7 +124,7 @@ foreach ( $offset_range as $offset ) {
}
?>
</select>
<?php _e('hours') ?>
<?php _e('hours'); ?>
<span id="utc-time"><?php printf(__('<abbr title="Coordinated Universal Time">UTC</abbr> time is <code>%s</code>'), date_i18n( $time_format, false, 'gmt')); ?></span>
<?php if ($current_offset) : ?>
<span id="local-time"><?php printf(__('UTC %1$s is <code>%2$s</code>'), $current_offset_name, date_i18n($time_format)); ?></span>

View File

@ -1106,7 +1106,7 @@ EOD;
$self_page = $page > 1 ? $page : NULL;
?><feed xmlns="<?php echo $this->ATOM_NS ?>" xmlns:app="<?php echo $this->ATOMPUB_NS ?>" xml:lang="<?php echo get_option('rss_language'); ?>">
<id><?php $this->the_entries_url() ?></id>
<updated><?php echo mysql2date('Y-m-d\TH:i:s\Z', get_lastpostmodified('GMT')); ?></updated>
<updated><?php echo mysql2date('Y-m-d\TH:i:s\Z', get_lastpostmodified('GMT'), false); ?></updated>
<title type="text"><?php bloginfo_rss('name') ?></title>
<subtitle type="text"><?php bloginfo_rss("description") ?></subtitle>
<link rel="first" type="<?php echo $this->ATOM_CONTENT_TYPE ?>" href="<?php $this->the_entries_url() ?>" />

View File

@ -353,7 +353,7 @@ function get_comment_class( $class = '', $comment_id = null, $post_id = null ) {
function get_comment_date( $d = '' ) {
global $comment;
if ( '' == $d )
$date = mysql2date( get_option('date_format'), $comment->comment_date);
$date = mysql2date(get_option('date_format'), $comment->comment_date);
else
$date = mysql2date($d, $comment->comment_date);
return apply_filters('get_comment_date', $date, $d);
@ -591,15 +591,16 @@ function comment_text() {
*
* @param string $d Optional. The format of the time (defaults to user's config)
* @param bool $gmt Whether to use the GMT date
* @param bool $translate Whether to translate the time (for use in feeds)
* @return string The formatted time
*/
function get_comment_time( $d = '', $gmt = false ) {
function get_comment_time( $d = '', $gmt = false, $translate = true ) {
global $comment;
$comment_date = $gmt? $comment->comment_date_gmt : $comment->comment_date;
if ( '' == $d )
$date = mysql2date(get_option('time_format'), $comment_date);
$date = mysql2date(get_option('time_format'), $comment_date, $translate);
else
$date = mysql2date($d, $comment_date);
$date = mysql2date($d, $comment_date, $translate);
return apply_filters('get_comment_time', $date, $d, $gmt);
}

View File

@ -464,8 +464,8 @@ function check_comment_flood_db( $ip, $email, $date ) {
if ( current_user_can( 'manage_options' ) )
return; // don't throttle admins
if ( $lasttime = $wpdb->get_var( $wpdb->prepare("SELECT comment_date_gmt FROM $wpdb->comments WHERE comment_author_IP = %s OR comment_author_email = %s ORDER BY comment_date DESC LIMIT 1", $ip, $email) ) ) {
$time_lastcomment = mysql2date('U', $lasttime);
$time_newcomment = mysql2date('U', $date);
$time_lastcomment = mysql2date('U', $lasttime, false);
$time_newcomment = mysql2date('U', $date, false);
$flood_die = apply_filters('comment_flood_filter', false, $time_lastcomment, $time_newcomment);
if ( $flood_die ) {
do_action('comment_flood_trigger', $time_lastcomment, $time_newcomment);

View File

@ -24,7 +24,7 @@ echo '<?xml version="1.0" encoding="' . get_option('blog_charset') . '" ?' . '>'
?></title>
<subtitle type="text"><?php bloginfo_rss('description'); ?></subtitle>
<updated><?php echo mysql2date('Y-m-d\TH:i:s\Z', get_lastcommentmodified('GMT')); ?></updated>
<updated><?php echo mysql2date('Y-m-d\TH:i:s\Z', get_lastcommentmodified('GMT'), false); ?></updated>
<?php the_generator( 'atom' ); ?>
<?php if ( is_singular() ) { ?>
@ -65,8 +65,8 @@ if ( have_comments() ) : while ( have_comments() ) : the_comment();
</author>
<id><?php comment_guid(); ?></id>
<updated><?php echo mysql2date('Y-m-d\TH:i:s\Z', get_comment_time('Y-m-d H:i:s', true), false); ?></updated>
<published><?php echo mysql2date('Y-m-d\TH:i:s\Z', get_comment_time('Y-m-d H:i:s', true), false); ?></published>
<updated><?php echo mysql2date('Y-m-d\TH:i:s\Z', get_comment_time('Y-m-d H:i:s', true, false), false); ?></updated>
<published><?php echo mysql2date('Y-m-d\TH:i:s\Z', get_comment_time('Y-m-d H:i:s', true, false), false); ?></published>
<?php if ( post_password_required($comment_post) ) : ?>
<content type="html" xml:base="<?php comment_link(); ?>"><![CDATA[<?php echo get_the_password_form(); ?>]]></content>
<?php else : // post pass ?>

View File

@ -19,7 +19,7 @@ echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>'; ?>
<title type="text"><?php bloginfo_rss('name'); wp_title_rss(); ?></title>
<subtitle type="text"><?php bloginfo_rss("description") ?></subtitle>
<updated><?php echo mysql2date('Y-m-d\TH:i:s\Z', get_lastpostmodified('GMT')); ?></updated>
<updated><?php echo mysql2date('Y-m-d\TH:i:s\Z', get_lastpostmodified('GMT'), false); ?></updated>
<?php the_generator( 'atom' ); ?>
<link rel="alternate" type="text/html" href="<?php bloginfo_rss('home') ?>" />

View File

@ -50,7 +50,7 @@ if ( have_comments() ) : while ( have_comments() ) : the_comment();
?></title>
<link><?php comment_link() ?></link>
<dc:creator><?php echo get_comment_author_rss() ?></dc:creator>
<pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_comment_time('Y-m-d H:i:s', true), false); ?></pubDate>
<pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_comment_time('Y-m-d H:i:s', true, false), false); ?></pubDate>
<guid isPermaLink="false"><?php comment_guid() ?></guid>
<?php if ( post_password_required($comment_post) ) : ?>
<description><?php echo ent2ncr(__('Protected Comments: Please enter your password to view comments.')); ?></description>

View File

@ -122,7 +122,7 @@ function date_i18n( $dateformatstring, $unixtimestamp = false, $gmt = false ) {
}
$j = @$datefunc( $dateformatstring, $i );
// allow plugins to redo this entirely for languages with untypical grammars
$j = apply_filters('date_i18n', $j, $req_format, $unixtimestamp, $gmt);
$j = apply_filters('date_i18n', $j, $req_format, $i, $gmt);
return $j;
}

View File

@ -1177,7 +1177,7 @@ function allowed_tags() {
*/
function the_date_xml() {
global $post;
echo mysql2date('Y-m-d', $post->post_date);
echo mysql2date('Y-m-d', $post->post_date, false);
}
/**
@ -1236,9 +1236,9 @@ function the_modified_date($d = '') {
*/
function get_the_modified_date($d = '') {
if ( '' == $d )
$the_time = get_post_modified_time(get_option('date_format'));
$the_time = get_post_modified_time(get_option('date_format'), null, null, true);
else
$the_time = get_post_modified_time($d);
$the_time = get_post_modified_time($d, null, null, true);
return apply_filters('get_the_modified_date', $the_time, $d);
}
@ -1266,9 +1266,9 @@ function get_the_time( $d = '', $post = null ) {
$post = get_post($post);
if ( '' == $d )
$the_time = get_post_time(get_option('time_format'), false, $post);
$the_time = get_post_time(get_option('time_format'), false, $post, true);
else
$the_time = get_post_time($d, false, $post);
$the_time = get_post_time($d, false, $post, true);
return apply_filters('get_the_time', $the_time, $d, $post);
}
@ -1280,9 +1280,10 @@ function get_the_time( $d = '', $post = null ) {
* @param string $d Either 'G', 'U', or php date format.
* @param bool $gmt Whether of not to return the gmt time.
* @param int|object $post Optional post ID or object. Default is global $post object.
* @param bool $translate Whether to translate the time string or not
* @return string
*/
function get_post_time( $d = 'U', $gmt = false, $post = null ) { // returns timestamp
function get_post_time( $d = 'U', $gmt = false, $post = null, $translate = false ) { // returns timestamp
$post = get_post($post);
if ( $gmt )
@ -1290,7 +1291,7 @@ function get_post_time( $d = 'U', $gmt = false, $post = null ) { // returns time
else
$time = $post->post_date;
$time = mysql2date($d, $time);
$time = mysql2date($d, $time, $translate);
return apply_filters('get_post_time', $time, $d, $gmt);
}
@ -1315,9 +1316,9 @@ function the_modified_time($d = '') {
*/
function get_the_modified_time($d = '') {
if ( '' == $d )
$the_time = get_post_modified_time(get_option('time_format'));
$the_time = get_post_modified_time(get_option('time_format'), null, null, true);
else
$the_time = get_post_modified_time($d);
$the_time = get_post_modified_time($d, null, null, true);
return apply_filters('get_the_modified_time', $the_time, $d);
}
@ -1328,16 +1329,18 @@ function get_the_modified_time($d = '') {
*
* @param string $d Either 'G', 'U', or php date format.
* @param bool $gmt Whether of not to return the gmt time.
* @param int|object $post A post_id or post object
* @param bool translate Whether to translate the result or not
* @return string Returns timestamp
*/
function get_post_modified_time( $d = 'U', $gmt = false ) {
global $post;
function get_post_modified_time( $d = 'U', $gmt = false, $post = null, $translate = false ) {
$post = get_post($post);
if ( $gmt )
$time = $post->post_modified_gmt;
else
$time = $post->post_modified;
$time = mysql2date($d, $time);
$time = mysql2date($d, $time, $translate);
return apply_filters('get_the_modified_time', $time, $d, $gmt);
}
@ -1351,7 +1354,7 @@ function get_post_modified_time( $d = 'U', $gmt = false ) {
*/
function the_weekday() {
global $wp_locale, $post;
$the_weekday = $wp_locale->get_weekday(mysql2date('w', $post->post_date));
$the_weekday = $wp_locale->get_weekday(mysql2date('w', $post->post_date, false));
$the_weekday = apply_filters('the_weekday', $the_weekday);
echo $the_weekday;
}
@ -1372,7 +1375,7 @@ function the_weekday_date($before='',$after='') {
$the_weekday_date = '';
if ( $day != $previousweekday ) {
$the_weekday_date .= $before;
$the_weekday_date .= $wp_locale->get_weekday(mysql2date('w', $post->post_date));
$the_weekday_date .= $wp_locale->get_weekday(mysql2date('w', $post->post_date, false));
$the_weekday_date .= $after;
$previousweekday = $day;
}

View File

@ -1467,7 +1467,7 @@ function wp_insert_post($postarr = array(), $wp_error = false) {
if ( 'publish' == $post_status ) {
$now = gmdate('Y-m-d H:i:59');
if ( mysql2date('U', $post_date_gmt) > mysql2date('U', $now) )
if ( mysql2date('U', $post_date_gmt, false) > mysql2date('U', $now, false) )
$post_status = 'future';
}

View File

@ -2660,8 +2660,8 @@ function setup_postdata($post) {
$authordata = get_userdata($post->post_author);
$day = mysql2date('d.m.y', $post->post_date);
$currentmonth = mysql2date('m', $post->post_date);
$day = mysql2date('d.m.y', $post->post_date, false);
$currentmonth = mysql2date('m', $post->post_date, false);
$numpages = 1;
$page = get_query_var('page');
if ( !$page )

View File

@ -523,8 +523,8 @@ class wp_xmlrpc_server extends IXR_Server {
$allow_pings = pings_open($page->ID) ? 1 : 0;
// Format page date.
$page_date = mysql2date("Ymd\TH:i:s", $page->post_date);
$page_date_gmt = mysql2date("Ymd\TH:i:s", $page->post_date_gmt);
$page_date = mysql2date("Ymd\TH:i:s", $page->post_date, false);
$page_date_gmt = mysql2date("Ymd\TH:i:s", $page->post_date_gmt, false);
// Pull the categories info together.
$categories = array();
@ -799,8 +799,8 @@ class wp_xmlrpc_server extends IXR_Server {
// The date needs to be formated 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);
$post_date_gmt = mysql2date("Ymd\TH:i:s", $page_list[$i]->post_date_gmt);
$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 = new IXR_Date($post_date);
$page_list[$i]->date_created_gmt = new IXR_Date($post_date_gmt);
@ -1047,8 +1047,8 @@ class wp_xmlrpc_server extends IXR_Server {
return new IXR_Error( 404, __( 'Invalid comment ID.' ) );
// Format page date.
$comment_date = mysql2date("Ymd\TH:i:s", $comment->comment_date);
$comment_date_gmt = mysql2date("Ymd\TH:i:s", $comment->comment_date_gmt);
$comment_date = mysql2date("Ymd\TH:i:s", $comment->comment_date, false);
$comment_date_gmt = mysql2date("Ymd\TH:i:s", $comment->comment_date_gmt, false);
if ( 0 == $comment->comment_approved )
$comment_status = 'hold';
@ -1679,7 +1679,7 @@ class wp_xmlrpc_server extends IXR_Server {
$struct = array(
'userid' => $post_data['post_author'],
'dateCreated' => new IXR_Date(mysql2date('Ymd\TH:i:s', $post_data['post_date'])),
'dateCreated' => new IXR_Date(mysql2date('Ymd\TH:i:s', $post_data['post_date'], false)),
'content' => $content,
'postid' => $post_data['ID']
);
@ -1721,7 +1721,7 @@ class wp_xmlrpc_server extends IXR_Server {
if( !current_user_can( 'edit_post', $entry['ID'] ) )
continue;
$post_date = mysql2date('Ymd\TH:i:s', $entry['post_date']);
$post_date = mysql2date('Ymd\TH:i:s', $entry['post_date'], false);
$categories = implode(',', wp_get_post_categories($entry['ID']));
$content = '<title>'.stripslashes($entry['post_title']).'</title>';
@ -2571,8 +2571,8 @@ class wp_xmlrpc_server extends IXR_Server {
$postdata = wp_get_single_post($post_ID, ARRAY_A);
if ($postdata['post_date'] != '') {
$post_date = mysql2date('Ymd\TH:i:s', $postdata['post_date']);
$post_date_gmt = mysql2date('Ymd\TH:i:s', $postdata['post_date_gmt']);
$post_date = mysql2date('Ymd\TH:i:s', $postdata['post_date'], false);
$post_date_gmt = mysql2date('Ymd\TH:i:s', $postdata['post_date_gmt'], false);
$categories = array();
$catids = wp_get_post_categories($post_ID);
@ -2687,8 +2687,8 @@ class wp_xmlrpc_server extends IXR_Server {
if( !current_user_can( 'edit_post', $entry['ID'] ) )
continue;
$post_date = mysql2date('Ymd\TH:i:s', $entry['post_date']);
$post_date_gmt = mysql2date('Ymd\TH:i:s', $entry['post_date_gmt']);
$post_date = mysql2date('Ymd\TH:i:s', $entry['post_date'], false);
$post_date_gmt = mysql2date('Ymd\TH:i:s', $entry['post_date_gmt'], false);
$categories = array();
$catids = wp_get_post_categories($entry['ID']);
@ -2922,8 +2922,8 @@ class wp_xmlrpc_server extends IXR_Server {
if( !current_user_can( 'edit_post', $entry['ID'] ) )
continue;
$post_date = mysql2date('Ymd\TH:i:s', $entry['post_date']);
$post_date_gmt = mysql2date('Ymd\TH:i:s', $entry['post_date_gmt']);
$post_date = mysql2date('Ymd\TH:i:s', $entry['post_date'], false);
$post_date_gmt = mysql2date('Ymd\TH:i:s', $entry['post_date_gmt'], false);
$struct[] = array(
'dateCreated' => new IXR_Date($post_date),