Make WordPress Core

Changeset 933


Ignore:
Timestamp:
02/25/2004 05:11:26 PM (21 years ago)
Author:
michelvaldrighi
Message:

zeroise() is our friend -- calendar fixed for GMT

File:
1 edited

Legend:

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

    r898 r933  
    321321    }
    322322    $time_difference = get_settings('time_difference');
     323    $add_hours = intval($time_difference);
     324    $add_minutes = intval(60 * ($time_difference - $add_hours));
     325    $wp_posts_post_date_field = "DATE_ADD(post_date, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE)";
    323326
    324327    // Let's figure out when we are
    325328    if (!empty($monthnum) && !empty($year)) {
    326         $thismonth = ''.intval($monthnum);
     329        $thismonth = ''.zeroise(intval($monthnum), 2);
    327330        $thisyear = ''.intval($year);
    328331    } elseif (!empty($w)) {
     
    337340            $thismonth = '01';
    338341        } else {
    339             $thismonth = ''.intval(substr($m, 4, 2));
    340         }
    341     } else {
    342         $thisyear = intval(date('Y', time()+($time_difference * 3600)));
    343         $thismonth = intval(date('m', time()+($time_difference * 3600)));
     342        $thismonth = ''.zeroise(intval(substr($m, 4, 2), 2));
     343        }
     344    } else {
     345        $thisyear = gmdate('Y', current_time('timestamp'));
     346        $thismonth = gmdate('m', current_time('timestamp'));
    344347    }
    345348
     
    347350
    348351    // Get the next and previous month and year with at least one post
    349     $previous = $wpdb->get_row("SELECT DISTINCT MONTH( post_date ) AS month, YEAR( post_date ) AS year
     352    $previous = $wpdb->get_row("SELECT DISTINCT MONTH(post_date) AS month, YEAR(post_date) AS year
    350353            FROM $tableposts
    351             WHERE post_date < '$thisyear-$thismonth-01'
     354            WHERE $wp_posts_post_date_field < '$thisyear-$thismonth-01'
    352355            AND post_status = 'publish'
    353356                              ORDER BY post_date DESC
    354357                              LIMIT 1");
    355     $next = $wpdb->get_row("SELECT  DISTINCT MONTH( post_date ) AS month, YEAR( post_date ) AS year
     358    $next = $wpdb->get_row("SELECT  DISTINCT MONTH($wp_posts_post_date_field) AS month, YEAR($wp_posts_post_date_field) AS year
    356359            FROM $tableposts
    357360            WHERE post_date >  '$thisyear-$thismonth-01'
     
    402405
    403406    // Get days with posts
    404     $dayswithposts = $wpdb->get_results("SELECT DISTINCT DAYOFMONTH(post_date)
    405             FROM $tableposts WHERE MONTH(post_date) = $thismonth
     407    $dayswithposts = $wpdb->get_results("SELECT DISTINCT DAYOFMONTH($wp_posts_post_date_field)
     408            FROM $tableposts WHERE MONTH($wp_posts_post_date_field) = $thismonth
    406409            AND YEAR(post_date) = $thisyear
    407410            AND post_status = 'publish'
    408             AND post_date < '" . date('Y-m-d H:i:s', (time() + ($time_difference * 3600))).'\'', ARRAY_N);
     411            AND post_date < '" . current_time('mysql') . '\'', ARRAY_N);
    409412    if ($dayswithposts) {
    410413        foreach ($dayswithposts as $daywith) {
     
    426429
    427430    $ak_titles_for_day = array();
    428     $ak_post_titles = $wpdb->get_results("SELECT post_title, DAYOFMONTH(post_date) as dom "
     431    $ak_post_titles = $wpdb->get_results("SELECT post_title, DAYOFMONTH($wp_posts_post_date_field) as dom "
    429432                                         ."FROM $tableposts "
    430                                          ."WHERE YEAR(post_date) = '$thisyear' "
    431                                          ."AND MONTH(post_date) = '$thismonth' "
    432                                          ."AND post_date < '".date("Y-m-d H:i:s", (time() + ($time_difference * 3600)))."' "
     433                                         ."WHERE YEAR($wp_posts_post_date_field) = '$thisyear' "
     434                                         ."AND MONTH($wp_posts_post_date_field) = '$thismonth' "
     435                                         ."AND post_date < '".current_time('mysql')."' "
    433436                                         ."AND post_status = 'publish'"
    434437                                        );
Note: See TracChangeset for help on using the changeset viewer.