Timezone fixes, I hope.

git-svn-id: https://develop.svn.wordpress.org/trunk@1150 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Matt Mullenweg
2004-04-24 21:52:24 +00:00
parent 286e32befa
commit 4b6149eecf
13 changed files with 31 additions and 37 deletions
+2 -4
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;
}
+8 -6
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);
+1 -1
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)) .')';
}
}
+9 -9
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>';
+5 -5
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;
+1 -1
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) {