Make WordPress Core

Ticket #9588: 9588.19.diff

File 9588.19.diff, 6.5 KB (added by ryan, 16 years ago)

It gets uglier.

  • wp-includes/post-template.php

     
    12101210        /* translators: 1: date */
    12111211        $currentf  = __( '%1$s [Current Revision]' );
    12121212
    1213         $date = date_i18n( $datef, strtotime( $revision->post_modified_gmt . ' +0000' ) );
     1213        $date = date_i18n( $datef, strtotime( $revision->post_modified ) );
    12141214        if ( $link && current_user_can( 'edit_post', $revision->ID ) && $link = get_edit_post_link( $revision->ID ) )
    12151215                $date = "<a href='$link'>$date</a>";
    12161216
  • wp-includes/functions.php

     
    5959 * @return int|string String if $type is 'gmt', int if $type is 'timestamp'.
    6060 */
    6161function current_time( $type, $gmt = 0 ) {
    62         switch ( $type ) {
    63                 case 'mysql':
    64                         return ( $gmt ) ? gmdate( 'Y-m-d H:i:s' ) : gmdate( 'Y-m-d H:i:s', ( time() + ( get_option( 'gmt_offset' ) * 3600 ) ) );
    65                         break;
    66                 case 'timestamp':
    67                         return ( $gmt ) ? time() : time() + ( get_option( 'gmt_offset' ) * 3600 );
    68                         break;
     62        if ( function_exists('date_default_timezone_set') ) {
     63                // Use the PHP5 DateTime support. The timezone is already correctly set.
     64                switch ( $type ) {
     65                        case 'mysql':
     66                                return ( $gmt ) ? gmdate( 'Y-m-d H:i:s' ) : date( 'Y-m-d H:i:s' );
     67                                break;
     68                        case 'timestamp':
     69                                return ( $gmt ) ? gmdate('U') : time();
     70                                break;
     71                }
     72        } else {
     73                // No PHP5 DateTime support. Add in gmt_offset.
     74                switch ( $type ) {
     75                        case 'mysql':
     76                                return ( $gmt ) ? gmdate( 'Y-m-d H:i:s') : gmdate( 'Y-m-d H:i:s', ( time() + ( get_option( 'gmt_offset' ) * 3600 ) ) );
     77                                break;
     78                        case 'timestamp':
     79                                return ( $gmt ) ? time() : ( time() + ( get_option( 'gmt_offset' ) * 3600 ) );
     80                                break;
     81                }
    6982        }
    7083}
    7184
     
    91104                if ( ! $gmt )
    92105                        $i = current_time( 'timestamp' );
    93106                else
    94                         $i = time();
     107                        $i = current_time( 'timestamp', true );
    95108                // we should not let date() interfere with our
    96109                // specially computed timestamp
    97                 $gmt = true;
     110                if ( !function_exists('date_default_timezone_set') )
     111                        $gmt = true;
    98112        }
    99113
    100114        // store original value for language with untypical grammars
    101115        // see http://core.trac.wordpress.org/ticket/9396
    102116        $req_format = $dateformatstring;
    103117
    104         $datefunc = $gmt? 'gmdate' : 'date';
     118        $datefunc = $gmt ? 'gmdate' : 'date';
    105119
    106120        if ( ( !empty( $wp_locale->month ) ) && ( !empty( $wp_locale->weekday ) ) ) {
    107121                $datemonth = $wp_locale->get_month( $datefunc( 'm', $i ) );
     
    127141}
    128142
    129143/**
     144 * WP wrapper for date() that hides differences between PHP4 and PHP 5 date and time support.
     145 *
     146 * @since 3.0
     147 *
     148 * @param string $format Format to display the date.
     149 * @param int $timestamp Optional. Unix timestamp.
     150 * @return string The formatted date
     151 */
     152function compat_date($format, $timestamp = false) {
     153        if ( function_exists('date_default_timezone_set') )
     154                return date($format, $timestamp);
     155        else
     156                return gmdate($format, $timestamp);
     157}
     158
     159/**
    130160 * Convert number to format based on the locale.
    131161 *
    132162 * @since 2.3.0
  • wp-settings.php

     
    1818set_magic_quotes_runtime(0);
    1919@ini_set('magic_quotes_sybase', 0);
    2020
    21 if ( function_exists('date_default_timezone_set') )
    22         date_default_timezone_set('UTC');
    23 
    2421/**
    2522 * Turn register globals off.
    2623 *
     
    719716// Load in support for template functions which the theme supports
    720717require_if_theme_supports( 'post-thumbnails', ABSPATH . WPINC . '/post-thumbnail-template.php' );
    721718
     719// Set the timezone
     720if ( function_exists('date_default_timezone_set') ) {
     721        if ( $timezone_string = get_option( 'timezone_string' ) )
     722                @date_default_timezone_set( $timezone_string );
     723        else
     724                @date_default_timezone_set(ini_get('date.timezone') ? ini_get('date.timezone') : 'UTC');
     725}
     726
    722727/**
    723728 * Runs just before PHP shuts down execution.
    724729 *
  • wp-admin/includes/meta-boxes.php

     
    165165        $date = date_i18n( $datef, strtotime( $post->post_date ) );
    166166} else { // draft (no saves, and thus no date specified)
    167167        $stamp = __('Publish <b>immediately</b>');
    168         $date = date_i18n( $datef, strtotime( current_time('mysql') ) );
     168        $date = date_i18n( $datef, current_time('timestamp') );
     169        error_log($date);
    169170}
    170171
    171172if ( $can_publish ) : // Contributors don't get to choose the date of publish ?>
  • wp-admin/includes/template.php

     
    26122612
    26132613        $time_adj = current_time('timestamp');
    26142614        $post_date = ($for_post) ? $post->post_date : $comment->comment_date;
    2615         $jj = ($edit) ? mysql2date( 'd', $post_date, false ) : gmdate( 'd', $time_adj );
    2616         $mm = ($edit) ? mysql2date( 'm', $post_date, false ) : gmdate( 'm', $time_adj );
    2617         $aa = ($edit) ? mysql2date( 'Y', $post_date, false ) : gmdate( 'Y', $time_adj );
    2618         $hh = ($edit) ? mysql2date( 'H', $post_date, false ) : gmdate( 'H', $time_adj );
    2619         $mn = ($edit) ? mysql2date( 'i', $post_date, false ) : gmdate( 'i', $time_adj );
    2620         $ss = ($edit) ? mysql2date( 's', $post_date, false ) : gmdate( 's', $time_adj );
     2615        $jj = ($edit) ? mysql2date( 'd', $post_date, false ) : compat_date( 'd', $time_adj );
     2616        $mm = ($edit) ? mysql2date( 'm', $post_date, false ) : compat_date( 'm', $time_adj );
     2617        $aa = ($edit) ? mysql2date( 'Y', $post_date, false ) : compat_date( 'Y', $time_adj );
     2618        $hh = ($edit) ? mysql2date( 'H', $post_date, false ) : compat_date( 'H', $time_adj );
     2619        $mn = ($edit) ? mysql2date( 'i', $post_date, false ) : compat_date( 'i', $time_adj );
     2620        $ss = ($edit) ? mysql2date( 's', $post_date, false ) : compat_date( 's', $time_adj );
    26212621
    2622         $cur_jj = gmdate( 'd', $time_adj );
    2623         $cur_mm = gmdate( 'm', $time_adj );
    2624         $cur_aa = gmdate( 'Y', $time_adj );
    2625         $cur_hh = gmdate( 'H', $time_adj );
    2626         $cur_mn = gmdate( 'i', $time_adj );
     2622        $cur_jj = compat_date( 'd', $time_adj );
     2623        $cur_mm = compat_date( 'm', $time_adj );
     2624        $cur_aa = compat_date( 'Y', $time_adj );
     2625        $cur_hh = compat_date( 'H', $time_adj );
     2626        $cur_mn = compat_date( 'i', $time_adj );
    26272627
    26282628        $month = "<select " . ( $multi ? '' : 'id="mm" ' ) . "name=\"mm\"$tab_index_attribute>\n";
    26292629        for ( $i = 1; $i < 13; $i = $i +1 ) {