Timezone fixes, I hope.

git-svn-id: http://svn.automattic.com/wordpress/trunk@1150 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
saxmatt 2004-04-24 21:52:24 +00:00
parent 06749585b5
commit 9945a746ec
13 changed files with 31 additions and 37 deletions

View File

@ -24,7 +24,6 @@ get_currentuserinfo();
$posts_per_page = get_settings('posts_per_page');
$what_to_show = get_settings('what_to_show');
$archive_mode = get_settings('archive_mode');
$time_difference = get_settings('time_difference');
$date_format = stripslashes(get_settings('date_format'));
$time_format = stripslashes(get_settings('time_format'));

View File

@ -98,12 +98,12 @@ include('options-head.php');
<tr>
<th scope="row"><?php _e('Default date format:') ?></th>
<td><input name="date_format" type="text" id="date_format" size="30" value="<?php echo get_settings('date_format'); ?>" /><br />
<?php _e('Output:') ?> <strong><?php echo date(get_settings('date_format'), current_time('timestamp', true)); ?></strong></td>
<?php _e('Output:') ?> <strong><?php echo gmdate(get_settings('date_format'), current_time('timestamp')); ?></strong></td>
</tr>
<tr>
<th scope="row"><?php _e('Default time format:') ?></th>
<td><input name="time_format" type="text" id="time_format" size="30" value="<?php echo get_settings('time_format'); ?>" /><br />
<?php _e('Output:') ?> <strong><?php echo date(get_settings('time_format'), current_time('timestamp', true)); ?></strong></td>
<?php _e('Output:') ?> <strong><?php echo gmdate(get_settings('time_format'), current_time('timestamp')); ?></strong></td>
</tr>
</table>
</fieldset>

View File

@ -9,8 +9,6 @@ get_currentuserinfo();
if ($user_level == 0)
die ("Cheatin' uh ?");
$time_difference = get_settings('time_difference');
if ('b' == $_GET['a']) {
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

View File

@ -110,7 +110,6 @@ if (!isset($posts_per_page) || $posts_per_page == 0)
$posts_per_page = get_settings('posts_per_page');
$what_to_show = get_settings('what_to_show');
$archive_mode = get_settings('archive_mode');
$time_difference = get_settings('time_difference');
$use_gzipcompression = get_settings('gzipcompression');
/* First let's clear some variables */
@ -129,8 +128,8 @@ if (isset($showposts) && $showposts) {
$posts_per_page = $showposts;
}
$add_hours = intval($time_difference);
$add_minutes = intval(60 * ($time_difference - $add_hours));
$add_hours = intval(get_settings('gmt_offset'));
$add_minutes = intval(60 * (get_settings('gmt_offset') - $add_hours));
$wp_posts_post_date_field = "post_date"; // "DATE_ADD(post_date, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE)";
// if a month is specified in the querystring, load that month

View File

@ -31,7 +31,7 @@ foreach ($posts as $post) { start_wp();
$tableposts.ID, $tableposts.post_password FROM $tablecomments
LEFT JOIN $tableposts ON comment_post_id = id WHERE comment_post_ID = '$id'
AND $tablecomments.comment_approved = '1' AND $tableposts.post_status = 'publish'
AND post_date < '".date("Y-m-d H:i:s")."'
AND post_date < '".date("Y-m-d H:i:59")."'
ORDER BY comment_date LIMIT " . get_settings('posts_per_rss') );
} else { // if no post id passed in, we'll just ue the last 10 comments.
$comments = $wpdb->get_results("SELECT comment_ID, comment_author, comment_author_email,

View File

@ -349,20 +349,18 @@ function wp_iso_descrambler($string) {
// give it a date, it will give you the same date as GMT
function get_gmt_from_date($string) {
// note: this only substracts $time_difference from the given date
$time_difference = get_settings('time_difference');
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 - $time_difference*3600);
$string_gmt = gmdate('Y-m-d H:i:s', $string_time - get_settings('gmt_offset') * 3600);
return $string_gmt;
}
// give it a GMT date, it will give you the same date with $time_difference added
function get_date_from_gmt($string) {
// note: this only adds $time_difference to the given date
$time_difference = get_settings('time_difference');
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 + $time_difference*3600);
$string_localtime = gmdate('Y-m-d H:i:s', $string_time + get_settings('gmt_offset')*3600);
return $string_localtime;
}

View File

@ -53,12 +53,14 @@ function current_time($type, $gmt = 0) {
$time_difference = get_settings('time_difference');
switch ($type) {
case 'mysql':
return ($gmt) ? gmdate('Y-m-d H:i:s')
: gmdate('Y-m-d H:i:s', (time() + ($time_difference * 3600)));;
if ($gmt) $d = gmdate('Y-m-d H:i:s');
else $d = gmdate('Y-m-d H:i:s', (time() + (get_settings('gmt_offset') * 3600)));
return $d;
break;
case 'timestamp':
return ($gmt) ? time()
: time() + ($time_difference * 3600);
if ($gmt) $d = time();
else $d = time() + (get_settings('gmt_offset') * 3600);
return $d;
break;
}
}
@ -435,7 +437,7 @@ function get_catname($cat_ID) {
}
function touch_time($edit = 1) {
global $month, $postdata, $time_difference;
global $month, $postdata;
// echo $postdata['Date'];
if ('draft' == $postdata['post_status']) {
$checked = 'checked="checked" ';
@ -446,7 +448,7 @@ function touch_time($edit = 1) {
echo '<p><input type="checkbox" class="checkbox" name="edit_date" value="1" id="timestamp" '.$checked.'/> <label for="timestamp">' . __('Edit timestamp') . '</label> <a href="http://wordpress.org/docs/reference/post/#edit_timestamp" title="' . __('Help on changing the timestamp') . '">?</a><br />';
$time_adj = time() + ($time_difference * 3600);
$time_adj = time() + (get_settings('gmt_offset') * 3600);
$post_date = $postdata['Date'];
$jj = ($edit) ? mysql2date('d', $post_date) : gmdate('d', $time_adj);
$mm = ($edit) ? mysql2date('m', $post_date) : gmdate('m', $time_adj);

View File

@ -186,7 +186,7 @@ function get_links($category = -1, $before = '', $after = '<br />',
if ($show_updated) {
if (substr($row->link_updated_f,0,2) != '00') {
$title .= ' (Last updated ' . date(get_settings('links_updated_date_format'), $row->link_updated_f + (get_settings('time_difference') * 3600)) .')';
$title .= ' (Last updated ' . date(get_settings('links_updated_date_format'), $row->link_updated_f + (get_settings('gmt_offset') * 3600)) .')';
}
}

View File

@ -219,7 +219,7 @@ function wp_get_archives($args = '') {
}
function get_archives($type='', $limit='', $format='html', $before = '', $after = '', $show_post_count = false) {
global $tableposts, $time_difference;
global $tableposts;
global $querystring_start, $querystring_equal, $querystring_separator, $month, $wpdb;
if ('' == $type) {
@ -254,8 +254,8 @@ function get_archives($type='', $limit='', $format='html', $before = '', $after
$archive_week_end_date_format = get_settings('date_format');
}
$add_hours = intval($time_difference);
$add_minutes = intval(60 * ($time_difference - $add_hours));
$add_hours = intval(get_settings('gmt_offset'));
$add_minutes = intval(60 * (get_settings('gmt_offset') - $add_hours));
$wp_posts_post_date_field = "post_date"; // "DATE_ADD(post_date, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE)";
$now = current_time('mysql');
@ -336,9 +336,9 @@ function get_calendar($daylength = 1) {
if (isset($_GET['w'])) {
$w = ''.intval($_GET['w']);
}
$time_difference = get_settings('time_difference');
$add_hours = intval($time_difference);
$add_minutes = intval(60 * ($time_difference - $add_hours));
$add_hours = intval(get_settings('gmt_offset'));
$add_minutes = intval(60 * (get_settings('gmt_offset') - $add_hours));
$wp_posts_post_date_field = "post_date"; // "DATE_ADD(post_date, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE)";
// Let's figure out when we are
@ -359,8 +359,8 @@ function get_calendar($daylength = 1) {
$thismonth = ''.zeroise(intval(substr($m, 4, 2)), 2);
}
} else {
$thisyear = gmdate('Y', current_time('timestamp') + $time_difference * 3600);
$thismonth = gmdate('m', current_time('timestamp') + $time_difference * 3600);
$thisyear = gmdate('Y', current_time('timestamp') + get_settings('gmt_offset') * 3600);
$thismonth = gmdate('m', current_time('timestamp') + get_settings('gmt_offset') * 3600);
}
$unixmonth = mktime(0, 0 , 0, $thismonth, 1, $thisyear);
@ -476,7 +476,7 @@ function get_calendar($daylength = 1) {
echo "\n\t</tr>\n\t<tr>\n\t\t";
$newrow = false;
if ($day == date('j', (time() + ($time_difference * 3600))) && $thismonth == date('m', time()+($time_difference * 3600)))
if ($day == date('j', (time() + (get_settings('gmt_offset') * 3600))) && $thismonth == date('m', time()+(get_settings('gmt_offset') * 3600)))
echo '<td id="today">';
else
echo '<td>';

View File

@ -87,8 +87,8 @@ function get_permalink($id=false) {
function get_month_link($year, $month) {
global $querystring_start, $querystring_equal;
if (!$year) $year = gmdate('Y', time()+($time_difference * 3600));
if (!$month) $month = gmdate('m', time()+($time_difference * 3600));
if (!$year) $year = gmdate('Y', time()+(get_settings('gmt_offset') * 3600));
if (!$month) $month = gmdate('m', time()+(get_settings('gmt_offset') * 3600));
if ('' != get_settings('permalink_structure')) {
$off = strpos(get_settings('permalink_structure'), '%monthnum%');
$offset = $off + 11;
@ -105,9 +105,9 @@ function get_month_link($year, $month) {
function get_day_link($year, $month, $day) {
global $querystring_start, $querystring_equal;
if (!$year) $year = gmdate('Y', time()+($time_difference * 3600));
if (!$month) $month = gmdate('m', time()+($time_difference * 3600));
if (!$day) $day = gmdate('j', time()+($time_difference * 3600));
if (!$year) $year = gmdate('Y', time()+(get_settings('gmt_offset') * 3600));
if (!$month) $month = gmdate('m', time()+(get_settings('gmt_offset') * 3600));
if (!$day) $day = gmdate('j', time()+(get_settings('gmt_offset') * 3600));
if ('' != get_settings('permalink_structure')) {
$off = strpos(get_settings('permalink_structure'), '%day%');
$offset = $off + 6;

View File

@ -315,7 +315,7 @@ function previous_post($format='%', $previous='previous post: ', $title='yes', $
function next_post($format='%', $next='next post: ', $title='yes', $in_same_cat='no', $limitnext=1, $excluded_categories='') {
global $tableposts, $p, $posts, $id, $post, $wpdb;
global $time_difference, $single;
global $single;
global $querystring_start, $querystring_equal, $querystring_separator;
if(($p) || ($posts==1) || 1 == $single) {

View File

@ -7,7 +7,6 @@ require_once(ABSPATH.WPINC.'/class-pop3.php');
timer_start();
$output_debugging_info = 0; # =1 if you want to output debugging info
$time_difference = get_settings('time_difference');
if (get_settings('use_phoneemail')) {
// if you're using phone email, the email will already be in your timezone

View File

@ -51,7 +51,6 @@ if ((strlen(''.$tb_id)) && (empty($_GET['__mode'])) && (strlen(''.$tb_url))) {
$user_ip = $_SERVER['REMOTE_ADDR'];
$user_domain = gethostbyaddr($user_ip);
$time_difference = get_settings('time_difference');
$now = current_time('mysql');
$now_gmt = current_time('mysql', 1);