From 84435bfa5f548f9ec0cedac8766acc17466f2e55 Mon Sep 17 00:00:00 2001 From: michelvaldrighi Date: Mon, 23 Feb 2004 03:42:40 +0000 Subject: [PATCH] big leap to GMT dates git-svn-id: http://svn.automattic.com/wordpress/trunk@914 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/post.php | 17 +++++------------ wp-admin/upgrade-functions.php | 9 +-------- wp-comments-post.php | 3 ++- wp-includes/functions.php | 11 ++++------- wp-mail.php | 4 ++-- wp-register.php | 2 +- wp-trackback.php | 2 +- 7 files changed, 16 insertions(+), 32 deletions(-) diff --git a/wp-admin/post.php b/wp-admin/post.php index 6ecb769763..43067a4938 100644 --- a/wp-admin/post.php +++ b/wp-admin/post.php @@ -83,11 +83,9 @@ switch($action) { $hh = ($hh > 23) ? $hh - 24 : $hh; $mn = ($mn > 59) ? $mn - 60 : $mn; $ss = ($ss > 59) ? $ss - 60 : $ss; - $now = "$aa-$mm-$jj $hh:$mn:$ss"; - // for GMT dates: compute GMT time from user's timezone time with time_difference + $now = get_gmt_from_date("$aa-$mm-$jj $hh:$mn:$ss") } else { - $now = current_time('mysql'); - // for GMT dates: $now = gmdate('Y-m-d H:i:s'); + $now = gmdate('Y-m-d H:i:s'); } if (!empty($HTTP_POST_VARS['mode'])) { @@ -310,17 +308,12 @@ switch($action) { $hh = ($hh > 23) ? $hh - 24 : $hh; $mn = ($mn > 59) ? $mn - 60 : $mn; $ss = ($ss > 59) ? $ss - 60 : $ss; - $datemodif = ", post_date=\"$aa-$mm-$jj $hh:$mn:$ss\""; - /* for GMT dates: - $add_hours = intval($time_difference); - $add_minutes = intval(60 * ($time_difference - $add_hours)); - $datemodif = ", post_date = DATE_ADD('$aa-$mm-$jj $hh:$mn:$ss', INTERVAL '-$add_hours:$add_minutes' HOUR_MINUTE)"; - */ + $datemodif = ", post_date = '".get_gmt_from_date('$aa-$mm-$jj $hh:$mn:$ss')."'"; } else { $datemodif = ''; } - $now = current_time('mysql'); - // for GMT dates: $now = gmdate('Y-m-d H:i:s'); + + $now = gmdate('Y-m-d H:i:s'); $result = $wpdb->query(" UPDATE $tableposts SET diff --git a/wp-admin/upgrade-functions.php b/wp-admin/upgrade-functions.php index 3f264c3282..cfe2888f1b 100644 --- a/wp-admin/upgrade-functions.php +++ b/wp-admin/upgrade-functions.php @@ -712,7 +712,7 @@ function upgrade_110() { $wpdb->query("INSERT INTO $tableoptions (option_id, option_name, option_type, option_value, option_description, option_admin_level) VALUES (93, 'blog_charset', 3, 'utf-8', 'Your blog’s charset (here’s a list of possible charsets)', 8)"); } - /* for GMT dates: this is commented until all of WP can deal with GMT + // Convert all datetime fields' values to GMT, and update $time_difference $time_difference = get_settings('time_difference'); $server_time = gmmktime(date('H'), date('i'), date('s'), date('m'), date('d'), date('Y')); @@ -731,12 +731,6 @@ function upgrade_110() { $add_hours = intval($diff_gmt_weblogger); $add_minutes = intval(60 * ($diff_gmt_weblogger - $add_hours)); - #field names to update: - #wp_posts.post_date - #wp_posts.post_modified - #wp_comments.comment_date - #wp_users.dateYMDhour - #the queries are simple $wpdb->query("UPDATE $tableposts SET post_date = DATE_ADD(post_date, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE)"); $wpdb->query("UPDATE $tableposts SET post_modified = DATE_ADD(post_date, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE) WHERE post_modified != '0000-00-00 00:00:00'"); @@ -753,7 +747,6 @@ function upgrade_110() { $wpdb->query("UPDATE $tableoptions SET option_value = '0' WHERE option_name = 'time_difference'"); } - */ } diff --git a/wp-comments-post.php b/wp-comments-post.php index e98c2ccd16..5c7372d25e 100644 --- a/wp-comments-post.php +++ b/wp-comments-post.php @@ -47,7 +47,8 @@ if ($comment == 'comment' || $comment == '') { } -$now = current_time('mysql'); +$now = gmdate('Y-m-d H:i:s'); + $comment = balanceTags($comment, 1); $comment = format_to_post($comment); diff --git a/wp-includes/functions.php b/wp-includes/functions.php index 7d4dc450dc..4f15c60f09 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -96,10 +96,9 @@ function get_weekstartend($mysqlstring, $start_of_week) { } function get_lastpostdate() { - global $tableposts, $cache_lastpostdate, $use_cache, $time_difference, $pagenow, $wpdb; + global $tableposts, $cache_lastpostdate, $use_cache, $pagenow, $wpdb; if ((!isset($cache_lastpostdate)) OR (!$use_cache)) { - $now = date("Y-m-d H:i:s",(time() + ($time_difference * 3600))); - + $now = gmdate('Y-m-d H:i:s'); $lastpostdate = $wpdb->get_var("SELECT post_date FROM $tableposts WHERE post_date <= '$now' AND post_status = 'publish' ORDER BY post_date DESC LIMIT 1"); $cache_lastpostdate = $lastpostdate; } else { @@ -111,9 +110,7 @@ function get_lastpostdate() { function get_lastpostmodified() { global $tableposts, $cache_lastpostmodified, $use_cache, $pagenow, $wpdb; if ((!isset($cache_lastpostmodified)) OR (!$use_cache)) { - $time_difference = get_settings('time_difference'); // for some weird reason the global wasn't set anymore? - $now = date("Y-m-d H:i:s",(time() + ($time_difference * 3600))); - + $now = gmdate('Y-m-d H:i:s'); $lastpostmodified = $wpdb->get_var("SELECT post_modified FROM $tableposts WHERE post_modified <= '$now' AND post_status = 'publish' ORDER BY post_modified DESC LIMIT 1"); $cache_lastpostmodified = $lastpostmodified; } else { @@ -1485,7 +1482,7 @@ function get_posts($args) { if (!isset($r['orderby'])) $r['orderby'] = ''; if (!isset($r['order'])) $r['order'] = ''; - $now = current_time('mysql'); + $now = gmdate('Y-m-d H:i:s'); $posts = $wpdb->get_results("SELECT DISTINCT * FROM $tableposts WHERE post_date <= '$now' AND (post_status = 'publish') GROUP BY $tableposts.ID ORDER BY post_date DESC LIMIT " . $r['offset'] . ',' . $r['numberposts']); diff --git a/wp-mail.php b/wp-mail.php index 239c74d2f0..3ad80798e7 100644 --- a/wp-mail.php +++ b/wp-mail.php @@ -106,8 +106,8 @@ for ($iCount=1; $iCount<=$Count; $iCount++) { } } $ddate_U = mktime($ddate_H, $ddate_i, $ddate_s, $ddate_m, $ddate_d, $ddate_Y); - $ddate_U = $ddate_U + ($time_difference * 3600); - $post_date = date('Y-m-d H:i:s', $ddate_U); + + $post_date = gmdate('Y-m-d H:i:s', $ddate_U); } } } diff --git a/wp-register.php b/wp-register.php index fff1c84bec..2d24079080 100644 --- a/wp-register.php +++ b/wp-register.php @@ -87,7 +87,7 @@ case 'register': $user_login = addslashes($user_login); $pass1 = addslashes($pass1); $user_nickname = addslashes($user_nickname); - $now = current_time('mysql'); + $now = gmdate('Y-m-d H:i:s'); $result = $wpdb->query("INSERT INTO $tableusers (user_login, user_pass, user_nickname, user_email, user_ip, user_domain, user_browser, dateYMDhour, user_level, user_idmode) diff --git a/wp-trackback.php b/wp-trackback.php index 0f35869704..4f80b5ac73 100644 --- a/wp-trackback.php +++ b/wp-trackback.php @@ -52,7 +52,7 @@ if ((strlen(''.$tb_id)) && (empty($HTTP_GET_VARS['__mode'])) && (strlen(''.$tb_u $user_ip = $HTTP_SERVER_VARS['REMOTE_ADDR']; $user_domain = gethostbyaddr($user_ip); $time_difference = get_settings('time_difference'); - $now = current_time('mysql'); + $now = gmdate('Y-m-d H:i:s'); $comment = convert_chars($comment); $comment = format_to_post($comment);