Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
07/21/2010 07:33:39 PM (16 years ago)
Author:
johnjamesjacoby
Message:

Fixes #2203 and #2497. Introduces bp_core_current_time function as central handler for all time related functions. Removes unused bp_core_format_time in lieu of currently used bp_format_time.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/1.2/bp-core.php

    r3133 r3142  
    12901290
    12911291/**
    1292  * bp_core_format_time()
    1293  */
    1294 function bp_core_format_time( $time, $just_date = false ) {
    1295         if ( !$time )
    1296                 return false;
    1297 
    1298         $date = date( "F j, Y ", $time );
    1299 
    1300         if ( !$just_date ) {
    1301                 $date .= __('at', 'buddypress') . date( ' g:iA', $time );
    1302         }
    1303 
    1304         return $date;
     1292 * bp_core_current_time()
     1293 *
     1294 * Get the current GMT time to save into the DB
     1295 *
     1296 * @package BuddyPress Core
     1297 * @since 1.2.6
     1298 */
     1299function bp_core_current_time() {
     1300        // Get current time in MYSQL format
     1301        $current_time = current_time( 'mysql', true );
     1302
     1303        return apply_filters( 'bp_core_current_time', $current_time );
    13051304}
    13061305
     
    14001399 */
    14011400function bp_core_time_since( $older_date, $newer_date = false ) {
     1401
    14021402        // array of time period chunks
    1403 
    14041403        $chunks = array(
    1405         array( 60 * 60 * 24 * 365 , __( 'year', 'buddypress' ), __( 'years', 'buddypress' ) ),
    1406         array( 60 * 60 * 24 * 30 , __( 'month', 'buddypress' ), __( 'months', 'buddypress' ) ),
    1407         array( 60 * 60 * 24 * 7, __( 'week', 'buddypress' ), __( 'weeks', 'buddypress' ) ),
    1408         array( 60 * 60 * 24 , __( 'day', 'buddypress' ), __( 'days', 'buddypress' ) ),
    1409         array( 60 * 60 , __( 'hour', 'buddypress' ), __( 'hours', 'buddypress' ) ),
    1410         array( 60 , __( 'minute', 'buddypress' ), __( 'minutes', 'buddypress' ) ),
    1411         array( 1, __( 'second', 'buddypress' ), __( 'seconds', 'buddypress' ) )
     1404                array( 60 * 60 * 24 * 365 , __( 'year', 'buddypress' ), __( 'years', 'buddypress' ) ),
     1405                array( 60 * 60 * 24 * 30 , __( 'month', 'buddypress' ), __( 'months', 'buddypress' ) ),
     1406                array( 60 * 60 * 24 * 7, __( 'week', 'buddypress' ), __( 'weeks', 'buddypress' ) ),
     1407                array( 60 * 60 * 24 , __( 'day', 'buddypress' ), __( 'days', 'buddypress' ) ),
     1408                array( 60 * 60 , __( 'hour', 'buddypress' ), __( 'hours', 'buddypress' ) ),
     1409                array( 60 , __( 'minute', 'buddypress' ), __( 'minutes', 'buddypress' ) ),
     1410                array( 1, __( 'second', 'buddypress' ), __( 'seconds', 'buddypress' ) )
    14121411        );
    14131412
     
    14211420        /* $newer_date will equal false if we want to know the time elapsed between a date and the current time */
    14221421        /* $newer_date will have a value if we want to work out time elapsed between two known dates */
    1423         $newer_date = ( !$newer_date ) ? gmmktime( gmdate( 'H' ), gmdate( 'i' ), gmdate( 's' ), gmdate( 'n' ), gmdate( 'j' ), gmdate( 'Y' ) ) : $newer_date;
     1422        $newer_date = ( !$newer_date ) ? strtotime( bp_core_current_time() ) : $newer_date;
    14241423
    14251424        /* Difference in seconds */
     
    14891488                $activity = strtotime( $activity );
    14901489
    1491         if ( '' == $activity || strtotime( gmdate( "Y-m-d H:i:s" ) ) >= strtotime( '+5 minutes', $activity ) )
    1492                 update_usermeta( $bp->loggedin_user->id, 'last_activity', gmdate( "Y-m-d H:i:s" ) );
     1490        // Get current time
     1491        $current_time = bp_core_current_time();
     1492
     1493        if ( '' == $activity || strtotime( $current_time ) >= strtotime( '+5 minutes', $activity ) )
     1494                update_usermeta( $bp->loggedin_user->id, 'last_activity', $current_time );
    14931495}
    14941496add_action( 'wp_head', 'bp_core_record_activity' );
Note: See TracChangeset for help on using the changeset viewer.