Making WordPress.org

Changeset 4459


Ignore:
Timestamp:
12/03/2016 02:40:25 PM (8 years ago)
Author:
coreymckrill
Message:

Add helper function wcord_get_wordcamp_duration

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/helper-functions.php

    r4379 r4459  
    260260    return $response;
    261261}
     262
     263/**
     264 * Take the start and end dates for a WordCamp and calculate how many days it lasts.
     265 *
     266 * @param WP_Post $wordcamp
     267 *
     268 * @return int
     269 */
     270function wcord_get_wordcamp_duration( WP_Post $wordcamp ) {
     271    $start = get_post_meta( $wordcamp->ID, 'Start Date (YYYY-mm-dd)', true );
     272    $end   = get_post_meta( $wordcamp->ID, 'End Date (YYYY-mm-dd)', true );
     273
     274    $duration_raw = $end - $start;
     275
     276    $duration_days = floor( $duration_raw / DAY_IN_SECONDS );
     277
     278    return absint( $duration_days );
     279}
Note: See TracChangeset for help on using the changeset viewer.