Making WordPress.org

Changeset 2578


Ignore:
Timestamp:
02/24/2016 07:38:44 PM (8 years ago)
Author:
kovshenin
Message:

WordCamp.org: Skip JPM holidays for value dates in NACHA exports.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-payments-network/includes/payment-requests-dashboard.php

    r2576 r2578  
    584584
    585585        echo 'Vendor Pay'; // Entry Description
    586         echo date( 'ymd', strtotime( 'today + 1 weekday' ) ); // Company Description Date
    587         echo date( 'ymd', strtotime( 'today + 1 weekday' ) ); // Effective Entry Date
     586        echo date( 'ymd', self::_next_business_day_timestamp() ); // Company Description Date
     587        echo date( 'ymd', self::_next_business_day_timestamp() ); // Effective Entry Date
    588588        echo str_pad( '', 3 ); // Blanks
    589589        echo '1'; // Originator Status Code
     
    682682        echo str_repeat( PHP_EOL, 10 - ( ( 4 + $count ) % 10 ) - 1 );
    683683        return ob_get_clean();
     684    }
     685
     686    /**
     687     * Exclude weekends and JPM holidays.
     688     *
     689     * Needs to be updated every year.
     690     *
     691     * @return int Timestamp.
     692     */
     693    private static function _next_business_day_timestamp() {
     694        static $timestamp;
     695
     696        if ( isset( $timestamp ) )
     697            return $timestamp;
     698
     699        $holidays = array(
     700            date( 'Ymd', strtotime( 'Friday, January 1, 2016' ) ),
     701            date( 'Ymd', strtotime( 'Monday, January 18, 2016' ) ),
     702            date( 'Ymd', strtotime( 'Monday, February 15, 2016' ) ),
     703            date( 'Ymd', strtotime( 'Monday, May 30, 2016' ) ),
     704            date( 'Ymd', strtotime( 'Monday, July 4, 2016' ) ),
     705            date( 'Ymd', strtotime( 'Monday, September 5, 2016' ) ),
     706            date( 'Ymd', strtotime( 'Friday, November 11, 2016' ) ),
     707            date( 'Ymd', strtotime( 'Thursday, November 24, 2016' ) ),
     708            date( 'Ymd', strtotime( 'Monday, December 26, 2016' ) ),
     709        );
     710
     711        $timestamp = strtotime( 'today + 1 weekday' );
     712        $attempts = 5;
     713
     714        while ( in_array( date( 'Ymd', $timestamp ), $holidays ) ) {
     715            $timestamp = strtotime( '+ 1 weekday', $timestamp );
     716            $attempts--;
     717
     718            if ( ! $attempts )
     719                break;
     720        }
     721
     722        return $timestamp;
    684723    }
    685724
Note: See TracChangeset for help on using the changeset viewer.