Make WordPress Core


Ignore:
Timestamp:
09/25/2012 05:26:19 AM (12 years ago)
Author:
nacin
Message:

Introduce constants to allow for easier expression of time periods in seconds. Adds MINUTE_IN_SECONDS, HOUR_IN_SECONDS, DAY_IN_SECONDS, WEEK_IN_SECONDS, YEAR_IN_SECONDS. props nbachiyski, SergeyBiryukov. fixes #20987.

File:
1 edited

Legend:

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

    r21922 r21996  
    6060    switch ( $type ) {
    6161        case 'mysql':
    62             return ( $gmt ) ? gmdate( 'Y-m-d H:i:s' ) : gmdate( 'Y-m-d H:i:s', ( time() + ( get_option( 'gmt_offset' ) * 3600 ) ) );
     62            return ( $gmt ) ? gmdate( 'Y-m-d H:i:s' ) : gmdate( 'Y-m-d H:i:s', ( time() + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ) ) );
    6363            break;
    6464        case 'timestamp':
    65             return ( $gmt ) ? time() : time() + ( get_option( 'gmt_offset' ) * 3600 );
     65            return ( $gmt ) ? time() : time() + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS );
    6666            break;
    6767    }
     
    215215        $weekday += 7;
    216216
    217     $start = $day - 86400 * ( $weekday - $start_of_week ); // The most recent week start day on or before $day
    218     $end = $start + 604799; // $start + 7 days - 1 second
     217    $start = $day - DAY_IN_SECONDS * ( $weekday - $start_of_week ); // The most recent week start day on or before $day
     218    $end = $start + 7 * DAY_IN_SECONDS - 1; // $start + 7 days - 1 second
    219219    return compact( 'start', 'end' );
    220220}
     
    935935 */
    936936function cache_javascript_headers() {
    937     $expiresOffset = 864000; // 10 days
     937    $expiresOffset = 10 * DAY_IN_SECONDS;
    938938    header( "Content-Type: text/javascript; charset=" . get_bloginfo( 'charset' ) );
    939939    header( "Vary: Accept-Encoding" ); // Handle proxies
     
    31183118        return false;
    31193119    }
    3120     return round( timezone_offset_get( $timezone_object, $datetime_object ) / 3600, 2 );
     3120    return round( timezone_offset_get( $timezone_object, $datetime_object ) / HOUR_IN_SECONDS, 2 );
    31213121}
    31223122
     
    33183318    global $wpdb;
    33193319
    3320     $delete_timestamp = time() - (60*60*24*EMPTY_TRASH_DAYS);
     3320    $delete_timestamp = time() - ( DAY_IN_SECONDS * EMPTY_TRASH_DAYS );
    33213321
    33223322    $posts_to_delete = $wpdb->get_results($wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_wp_trash_meta_time' AND meta_value < '%d'", $delete_timestamp), ARRAY_A);
Note: See TracChangeset for help on using the changeset viewer.