From 1354d0660ae6d805c6b1305f7c361394aecca62e Mon Sep 17 00:00:00 2001 From: ryan Date: Thu, 14 May 2009 02:00:32 +0000 Subject: [PATCH] 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 --- wp-admin/edit-attachment-rows.php | 2 +- wp-admin/edit-form-advanced.php | 2 +- wp-admin/edit-page-form.php | 2 +- wp-admin/includes/template.php | 24 +++++++++++------------ wp-admin/includes/upgrade.php | 2 +- wp-admin/options-general.php | 4 ++-- wp-app.php | 2 +- wp-includes/comment-template.php | 9 +++++---- wp-includes/comment.php | 4 ++-- wp-includes/feed-atom-comments.php | 6 +++--- wp-includes/feed-atom.php | 2 +- wp-includes/feed-rss2-comments.php | 2 +- wp-includes/functions.php | 2 +- wp-includes/general-template.php | 31 ++++++++++++++++-------------- wp-includes/post.php | 2 +- wp-includes/query.php | 4 ++-- xmlrpc.php | 28 +++++++++++++-------------- 17 files changed, 66 insertions(+), 62 deletions(-) diff --git a/wp-admin/edit-attachment-rows.php b/wp-admin/edit-attachment-rows.php index c0297ed4ff..27fdaeb5e9 100644 --- a/wp-admin/edit-attachment-rows.php +++ b/wp-admin/edit-attachment-rows.php @@ -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 ) ); diff --git a/wp-admin/edit-form-advanced.php b/wp-admin/edit-form-advanced.php index 0015bd0d26..ad84a9a2a2 100644 --- a/wp-admin/edit-form-advanced.php +++ b/wp-admin/edit-form-advanced.php @@ -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 ) ); diff --git a/wp-admin/edit-page-form.php b/wp-admin/edit-page-form.php index 5e013d8845..88f9f7765e 100644 --- a/wp-admin/edit-page-form.php +++ b/wp-admin/edit-page-form.php @@ -41,7 +41,7 @@ if ( 0 == $post_ID) { $nonce_action = 'update-page_' . $post_ID; $form_extra = ""; $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 ) ); } diff --git a/wp-admin/includes/template.php b/wp-admin/includes/template.php index b5d036fef2..a5608650c6 100644 --- a/wp-admin/includes/template.php +++ b/wp-admin/includes/template.php @@ -1298,12 +1298,12 @@ function get_inline_data($post) {
' . $post->comment_status . '
' . $post->ping_status . '
' . $post->post_status . '
-
' . mysql2date( 'd', $post->post_date ) . '
-
' . mysql2date( 'm', $post->post_date ) . '
-
' . mysql2date( 'Y', $post->post_date ) . '
-
' . mysql2date( 'H', $post->post_date ) . '
-
' . mysql2date( 'i', $post->post_date ) . '
-
' . mysql2date( 's', $post->post_date ) . '
+
' . mysql2date( 'd', $post->post_date, false ) . '
+
' . mysql2date( 'm', $post->post_date, false ) . '
+
' . mysql2date( 'Y', $post->post_date, false ) . '
+
' . mysql2date( 'H', $post->post_date, false ) . '
+
' . mysql2date( 'i', $post->post_date, false ) . '
+
' . mysql2date( 's', $post->post_date, false ) . '
' . wp_specialchars($post->post_password, 1) . '
'; 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 ); diff --git a/wp-admin/includes/upgrade.php b/wp-admin/includes/upgrade.php index 0743d98e9f..331e23415a 100644 --- a/wp-admin/includes/upgrade.php +++ b/wp-admin/includes/upgrade.php @@ -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)); } } diff --git a/wp-admin/options-general.php b/wp-admin/options-general.php index 8573768a00..8cc00f3090 100644 --- a/wp-admin/options-general.php +++ b/wp-admin/options-general.php @@ -96,7 +96,7 @@ include('./admin-header.php'); @@ -124,7 +124,7 @@ foreach ( $offset_range as $offset ) { } ?> - + UTC time is %s'), date_i18n( $time_format, false, 'gmt')); ?> %2$s'), $current_offset_name, date_i18n($time_format)); ?> diff --git a/wp-app.php b/wp-app.php index 7762e6ce7f..889a63b442 100644 --- a/wp-app.php +++ b/wp-app.php @@ -1106,7 +1106,7 @@ EOD; $self_page = $page > 1 ? $page : NULL; ?> the_entries_url() ?> - + <?php bloginfo_rss('name') ?> diff --git a/wp-includes/comment-template.php b/wp-includes/comment-template.php index e67032c54c..c164055aa8 100644 --- a/wp-includes/comment-template.php +++ b/wp-includes/comment-template.php @@ -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); } diff --git a/wp-includes/comment.php b/wp-includes/comment.php index 91833fb571..615b2e2690 100644 --- a/wp-includes/comment.php +++ b/wp-includes/comment.php @@ -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); diff --git a/wp-includes/feed-atom-comments.php b/wp-includes/feed-atom-comments.php index 545425c3d7..7f7e6f511a 100644 --- a/wp-includes/feed-atom-comments.php +++ b/wp-includes/feed-atom-comments.php @@ -24,7 +24,7 @@ echo '' ?> - + @@ -65,8 +65,8 @@ if ( have_comments() ) : while ( have_comments() ) : the_comment(); - - + + ]]> diff --git a/wp-includes/feed-atom.php b/wp-includes/feed-atom.php index ebb316dc4d..dad299129d 100644 --- a/wp-includes/feed-atom.php +++ b/wp-includes/feed-atom.php @@ -19,7 +19,7 @@ echo ''; ?> <?php bloginfo_rss('name'); wp_title_rss(); ?> - + diff --git a/wp-includes/feed-rss2-comments.php b/wp-includes/feed-rss2-comments.php index e1d730a15e..d5ea2cc5ea 100644 --- a/wp-includes/feed-rss2-comments.php +++ b/wp-includes/feed-rss2-comments.php @@ -50,7 +50,7 @@ if ( have_comments() ) : while ( have_comments() ) : the_comment(); ?> - + diff --git a/wp-includes/functions.php b/wp-includes/functions.php index 648ce66da4..99f5307595 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -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; } diff --git a/wp-includes/general-template.php b/wp-includes/general-template.php index a89560a771..815b4b9ceb 100644 --- a/wp-includes/general-template.php +++ b/wp-includes/general-template.php @@ -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; } diff --git a/wp-includes/post.php b/wp-includes/post.php index f6d0cfa1d4..a25afaad2c 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -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'; } diff --git a/wp-includes/query.php b/wp-includes/query.php index 3efe2f4732..161d725292 100644 --- a/wp-includes/query.php +++ b/wp-includes/query.php @@ -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 ) diff --git a/xmlrpc.php b/xmlrpc.php index 5e177802f6..08e137af01 100644 --- a/xmlrpc.php +++ b/xmlrpc.php @@ -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 = ''.stripslashes($entry['post_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),