57 lines
1.4 KiB
PHP
57 lines
1.4 KiB
PHP
<?php
|
|
|
|
|
|
namespace customerapi\models\available;
|
|
|
|
|
|
use DateTime;
|
|
|
|
/**
|
|
* Class DateIntervalHelper
|
|
* @package customerapi\models\available
|
|
* @property \DateTime $firstActiveDate
|
|
* @property \DateTime $lastActiveDate
|
|
* @property \DateTime $firstDisplayDate
|
|
* @property \DateTime $lastDisplayDate
|
|
*/
|
|
class EventInterval
|
|
{
|
|
|
|
public $countOfActiveDays = 14;
|
|
public $daysToDisplay = 21;
|
|
|
|
|
|
public $firstActiveDate;
|
|
public $lastActiveDate;
|
|
public $firstDisplayDate;
|
|
public $lastDisplayDate;
|
|
|
|
private function __construct()
|
|
{
|
|
|
|
$firstActiveDay = new DateTime();
|
|
$firstActiveDay->setTime(0, 0);
|
|
$this->firstActiveDate = $firstActiveDay;
|
|
|
|
$lastActiveDay = new DateTime();
|
|
$lastActiveDay->setTime(0, 0);
|
|
$lastActiveDay->modify('+' . $this->countOfActiveDays . ' day');
|
|
$this->lastActiveDate = $lastActiveDay;
|
|
|
|
$firstDisplayDate = new DateTime();
|
|
$firstDisplayDate->modify('this week');
|
|
$firstDisplayDate->setTime(0, 0);
|
|
$this->firstDisplayDate = $firstDisplayDate;
|
|
|
|
$lastDisplayDate = clone $firstDisplayDate;
|
|
$lastDisplayDate->setTime(0, 0);
|
|
$lastDisplayDate->modify('+' . $this->daysToDisplay . ' day');
|
|
$this->lastDisplayDate = $lastDisplayDate;
|
|
|
|
}
|
|
|
|
public static function createInterval(){
|
|
return new EventInterval();
|
|
}
|
|
}
|