Fix #3
This commit is contained in:
@@ -1,4 +1,94 @@
|
|||||||
<?php
|
<?php
|
||||||
|
if( !function_exists( 'date_diff' ) ) {
|
||||||
|
class DateInterval {
|
||||||
|
public $y;
|
||||||
|
public $m;
|
||||||
|
public $d;
|
||||||
|
public $h;
|
||||||
|
public $i;
|
||||||
|
public $s;
|
||||||
|
public $invert;
|
||||||
|
public $days;
|
||||||
|
|
||||||
|
public function format($format) {
|
||||||
|
$format = str_replace('%R%y',
|
||||||
|
($this->invert ? '-' : '+') . $this->y, $format);
|
||||||
|
$format = str_replace('%R%m',
|
||||||
|
($this->invert ? '-' : '+') . $this->m, $format);
|
||||||
|
$format = str_replace('%R%d',
|
||||||
|
($this->invert ? '-' : '+') . $this->d, $format);
|
||||||
|
$format = str_replace('%R%h',
|
||||||
|
($this->invert ? '-' : '+') . $this->h, $format);
|
||||||
|
$format = str_replace('%R%i',
|
||||||
|
($this->invert ? '-' : '+') . $this->i, $format);
|
||||||
|
$format = str_replace('%R%s',
|
||||||
|
($this->invert ? '-' : '+') . $this->s, $format);
|
||||||
|
|
||||||
|
$format = str_replace('%y', $this->y, $format);
|
||||||
|
$format = str_replace('%m', $this->m, $format);
|
||||||
|
$format = str_replace('%d', $this->d, $format);
|
||||||
|
$format = str_replace('%h', $this->h, $format);
|
||||||
|
$format = str_replace('%i', $this->i, $format);
|
||||||
|
$format = str_replace('%s', $this->s, $format);
|
||||||
|
|
||||||
|
return $format;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function date_diff(DateTime $date1, DateTime $date2) {
|
||||||
|
|
||||||
|
$diff = new DateInterval();
|
||||||
|
|
||||||
|
if($date1 > $date2) {
|
||||||
|
$tmp = $date1;
|
||||||
|
$date1 = $date2;
|
||||||
|
$date2 = $tmp;
|
||||||
|
$diff->invert = 1;
|
||||||
|
} else {
|
||||||
|
$diff->invert = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
$diff->y = ((int) $date2->format('Y')) - ((int) $date1->format('Y'));
|
||||||
|
$diff->m = ((int) $date2->format('n')) - ((int) $date1->format('n'));
|
||||||
|
if($diff->m < 0) {
|
||||||
|
$diff->y -= 1;
|
||||||
|
$diff->m = $diff->m + 12;
|
||||||
|
}
|
||||||
|
$diff->d = ((int) $date2->format('j')) - ((int) $date1->format('j'));
|
||||||
|
if($diff->d < 0) {
|
||||||
|
$diff->m -= 1;
|
||||||
|
$diff->d = $diff->d + ((int) $date1->format('t'));
|
||||||
|
}
|
||||||
|
$diff->h = ((int) $date2->format('G')) - ((int) $date1->format('G'));
|
||||||
|
if($diff->h < 0) {
|
||||||
|
$diff->d -= 1;
|
||||||
|
$diff->h = $diff->h + 24;
|
||||||
|
}
|
||||||
|
$diff->i = ((int) $date2->format('i')) - ((int) $date1->format('i'));
|
||||||
|
if($diff->i < 0) {
|
||||||
|
$diff->h -= 1;
|
||||||
|
$diff->i = $diff->i + 60;
|
||||||
|
}
|
||||||
|
$diff->s = ((int) $date2->format('s')) - ((int) $date1->format('s'));
|
||||||
|
if($diff->s < 0) {
|
||||||
|
$diff->i -= 1;
|
||||||
|
$diff->s = $diff->s + 60;
|
||||||
|
}
|
||||||
|
|
||||||
|
$start_ts = $date1->format('U');
|
||||||
|
$end_ts = $date2->format('U');
|
||||||
|
$days = $end_ts - $start_ts;
|
||||||
|
$diff->days = round($days / 86400);
|
||||||
|
|
||||||
|
if (($diff->h > 0 || $diff->i > 0 || $diff->s > 0))
|
||||||
|
$diff->days += ((bool) $diff->invert)
|
||||||
|
? 1
|
||||||
|
: -1;
|
||||||
|
|
||||||
|
return $diff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( !function_exists( 'sportspress_nonce' ) ) {
|
if ( !function_exists( 'sportspress_nonce' ) ) {
|
||||||
function sportspress_nonce() {
|
function sportspress_nonce() {
|
||||||
echo '<input type="hidden" name="sportspress_nonce" id="sportspress_nonce" value="' . wp_create_nonce( SPORTSPRESS_PLUGIN_BASENAME ) . '" />';
|
echo '<input type="hidden" name="sportspress_nonce" id="sportspress_nonce" value="' . wp_create_nonce( SPORTSPRESS_PLUGIN_BASENAME ) . '" />';
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ Tags: sports, sports journalism, teams, team management, fixtures, results, stan
|
|||||||
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=support@themeboy.com&item_name=Donation+for+SportsPress
|
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=support@themeboy.com&item_name=Donation+for+SportsPress
|
||||||
Requires at least: 3.8
|
Requires at least: 3.8
|
||||||
Tested up to: 3.8.1
|
Tested up to: 3.8.1
|
||||||
Stable tag: 0.4
|
Stable tag: 0.4.1
|
||||||
License: GPLv3
|
License: GPLv3
|
||||||
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
Plugin Name: SportsPress
|
Plugin Name: SportsPress
|
||||||
Plugin URI: http://themeboy.com/sportspress
|
Plugin URI: http://themeboy.com/sportspress
|
||||||
Description: Manage your club and its players, staff, events, league tables, and player lists.
|
Description: Manage your club and its players, staff, events, league tables, and player lists.
|
||||||
Version: 0.4
|
Version: 0.4.1
|
||||||
Author: ThemeBoy
|
Author: ThemeBoy
|
||||||
Author URI: http://themeboy.com/
|
Author URI: http://themeboy.com/
|
||||||
License: GPLv3
|
License: GPLv3
|
||||||
@@ -18,7 +18,7 @@ if ( !function_exists( 'add_action' ) ):
|
|||||||
exit;
|
exit;
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
define( 'SPORTSPRESS_VERSION', '0.4' );
|
define( 'SPORTSPRESS_VERSION', '0.4.1' );
|
||||||
define( 'SPORTSPRESS_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
|
define( 'SPORTSPRESS_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
|
||||||
define( 'SPORTSPRESS_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
|
define( 'SPORTSPRESS_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
|
||||||
define( 'SPORTSPRESS_PLUGIN_FILE', __FILE__ );
|
define( 'SPORTSPRESS_PLUGIN_FILE', __FILE__ );
|
||||||
|
|||||||
Reference in New Issue
Block a user