Changeset 996

Show
Ignore:
Timestamp:
03/25/04 01:45:07 (5 years ago)
Author:
michelvaldrighi
Message:

calendar, archives, date, time, you name it, it's back to localtime

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/wp-includes/template-functions-general.php

    r973 r996  
    241241    $add_hours = intval($time_difference); 
    242242    $add_minutes = intval(60 * ($time_difference - $add_hours)); 
    243     $wp_posts_post_date_field = "DATE_ADD(post_date, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE)"; 
     243    $wp_posts_post_date_field = "post_date"; // "DATE_ADD(post_date, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE)"; 
    244244 
    245245    $now = current_time('mysql'); 
    246246 
    247247    if ('monthly' == $type) { 
    248         $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR($wp_posts_post_date_field) AS `year`, MONTH($wp_posts_post_date_field) AS `month`, count(ID) as posts FROM $tableposts WHERE post_date < '$now' AND post_status = 'publish' GROUP BY YEAR($wp_posts_post_date_field), MONTH($wp_posts_post_date_field) ORDER BY post_date DESC" . $limit); 
     248        $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM $tableposts WHERE post_date < '$now' AND post_status = 'publish' GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC" . $limit); 
    249249        if ($arcresults) { 
    250250            foreach ($arcresults as $arcresult) { 
     
    260260        } 
    261261    } elseif ('daily' == $type) { 
    262         $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR($wp_posts_post_date_field) AS `year`, MONTH($wp_posts_post_date_field) AS `month`, DAYOFMONTH($wp_posts_post_date_field) AS `dayofmonth` FROM $tableposts WHERE post_date < '$now' AND post_status = 'publish' ORDER BY post_date DESC" . $limit); 
     262        $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth` FROM $tableposts WHERE post_date < '$now' AND post_status = 'publish' ORDER BY post_date DESC" . $limit); 
    263263        if ($arcresults) { 
    264264            foreach ($arcresults as $arcresult) { 
     
    271271    } elseif ('weekly' == $type) { 
    272272    $start_of_week = get_settings('start_of_week'); 
    273         $arcresults = $wpdb->get_results("SELECT DISTINCT WEEK($wp_posts_post_date_field, $start_of_week) AS `week`, YEAR($wp_posts_post_date_field) AS yr, DATE_FORMAT($wp_posts_post_date_field, '%Y-%m-%d') AS yyyymmdd FROM $tableposts WHERE post_date < '$now' AND post_status = 'publish' ORDER BY post_date DESC" . $limit); 
     273        $arcresults = $wpdb->get_results("SELECT DISTINCT WEEK(post_date, $start_of_week) AS `week`, YEAR(post_date) AS yr, DATE_FORMAT(post_date, '%Y-%m-%d') AS yyyymmdd FROM $tableposts WHERE post_date < '$now' AND post_status = 'publish' ORDER BY post_date DESC" . $limit); 
    274274        $arc_w_last = ''; 
    275275        if ($arcresults) { 
     
    290290        } 
    291291    } elseif ('postbypost' == $type) { 
    292         $arcresults = $wpdb->get_results("SELECT ID, $wp_posts_post_date_field, post_title FROM $tableposts WHERE post_date < '$now' AND post_status = 'publish' ORDER BY post_date DESC" . $limit); 
     292        $arcresults = $wpdb->get_results("SELECT ID, post_date, post_title FROM $tableposts WHERE post_date < '$now' AND post_status = 'publish' ORDER BY post_date DESC" . $limit); 
    293293        if ($arcresults) { 
    294294            foreach ($arcresults as $arcresult) { 
     
    324324    $add_hours = intval($time_difference); 
    325325    $add_minutes = intval(60 * ($time_difference - $add_hours)); 
    326     $wp_posts_post_date_field = "DATE_ADD(post_date, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE)"; 
     326    $wp_posts_post_date_field = "post_date"; // "DATE_ADD(post_date, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE)"; 
    327327 
    328328    // Let's figure out when we are 
     
    344344        } 
    345345    } else { 
    346         $thisyear = gmdate('Y', current_time('timestamp')); 
    347         $thismonth = gmdate('m', current_time('timestamp')); 
     346        $thisyear = gmdate('Y', current_time('timestamp') + $time_difference * 3600); 
     347        $thismonth = gmdate('m', current_time('timestamp') + $time_difference * 3600); 
    348348    } 
    349349 
     
    353353    $previous = $wpdb->get_row("SELECT DISTINCT MONTH(post_date) AS month, YEAR(post_date) AS year 
    354354            FROM $tableposts 
    355             WHERE $wp_posts_post_date_field < '$thisyear-$thismonth-01' 
     355            WHERE post_date < '$thisyear-$thismonth-01' 
    356356            AND post_status = 'publish' 
    357357                              ORDER BY post_date DESC 
    358358                              LIMIT 1"); 
    359     $next = $wpdb->get_row("SELECT  DISTINCT MONTH($wp_posts_post_date_field) AS month, YEAR($wp_posts_post_date_field) AS year 
     359    $next = $wpdb->get_row("SELECT  DISTINCT MONTH(post_date) AS month, YEAR(post_date) AS year 
    360360            FROM $tableposts 
    361361            WHERE post_date >  '$thisyear-$thismonth-01' 
     
    406406 
    407407    // Get days with posts 
    408     $dayswithposts = $wpdb->get_results("SELECT DISTINCT DAYOFMONTH($wp_posts_post_date_field
    409             FROM $tableposts WHERE MONTH($wp_posts_post_date_field) = $thismonth 
     408    $dayswithposts = $wpdb->get_results("SELECT DISTINCT DAYOFMONTH(post_date
     409            FROM $tableposts WHERE MONTH(post_date) = $thismonth 
    410410            AND YEAR(post_date) = $thisyear 
    411411            AND post_status = 'publish' 
     
    430430 
    431431    $ak_titles_for_day = array(); 
    432     $ak_post_titles = $wpdb->get_results("SELECT post_title, DAYOFMONTH($wp_posts_post_date_field) as dom " 
     432    $ak_post_titles = $wpdb->get_results("SELECT post_title, DAYOFMONTH(post_date) as dom " 
    433433                                         ."FROM $tableposts " 
    434                                          ."WHERE YEAR($wp_posts_post_date_field) = '$thisyear' " 
    435                                          ."AND MONTH($wp_posts_post_date_field) = '$thismonth' " 
     434                                         ."WHERE YEAR(post_date) = '$thisyear' " 
     435                                         ."AND MONTH(post_date) = '$thismonth' " 
    436436                                         ."AND post_date < '".current_time('mysql')."' " 
    437437                                         ."AND post_status = 'publish'" 
     
    502502function the_date_xml() { 
    503503    global $post; 
    504     echo mysql2date('Y-m-d', get_date_from_gmt($post->post_date)); 
     504    echo mysql2date('Y-m-d', $post->post_date); 
    505505    //echo ""+$post->post_date; 
    506506} 
     
    512512        $the_date .= $before; 
    513513        if ($d=='') { 
    514         $the_date .= mysql2date(get_settings('date_format'), get_date_from_gmt($post->post_date)); 
     514        $the_date .= mysql2date(get_settings('date_format'), $post->post_date); 
    515515        } else { 
    516         $the_date .= mysql2date($d, get_date_from_gmt($post->post_date)); 
     516        $the_date .= mysql2date($d, $post->post_date); 
    517517        } 
    518518        $the_date .= $after; 
     
    530530    global $id, $post; 
    531531    if ($d=='') { 
    532         $the_time = mysql2date(get_settings('time_format'), get_date_from_gmt($post->post_date)); 
    533     } else { 
    534         $the_time = mysql2date($d, get_date_from_gmt($post->post_date)); 
     532        $the_time = mysql2date(get_settings('time_format'), $post->post_date); 
     533    } else { 
     534        $the_time = mysql2date($d, $post->post_date); 
    535535    } 
    536536    $the_time = apply_filters('the_time', $the_time); 
     
    544544function the_weekday() { 
    545545    global $weekday, $id, $post; 
    546     $the_weekday = $weekday[mysql2date('w', get_date_from_gmt($post->post_date))]; 
     546    $the_weekday = $weekday[mysql2date('w', $post->post_date)]; 
    547547    $the_weekday = apply_filters('the_weekday', $the_weekday); 
    548548    echo $the_weekday; 
     
    554554    if ($day != $previousweekday) { 
    555555        $the_weekday_date .= $before; 
    556         $the_weekday_date .= $weekday[mysql2date('w', get_date_from_gmt($post->post_date))]; 
     556        $the_weekday_date .= $weekday[mysql2date('w', $post->post_date)]; 
    557557        $the_weekday_date .= $after; 
    558558        $previousweekday = $day;