Scalr\Stats\CostAnalytics\Iterator\ChartDailyIterator::__construct PHP Метод

__construct() публичный Метод

Constructor
public __construct ( string $start, string $end = null, string $timezone = 'UTC' )
$start string The start date of the period 'YYYY-mm-dd'
$end string optional End date
$timezone string optional Timezone
    public function __construct($start, $end = null, $timezone = 'UTC')
    {
        $this->mode = 'day';
        $this->timezone = new DateTimeZone($timezone);
        $this->today = $this->getTodayDate();
        $this->start = new DateTime($start instanceof DateTime ? $start->format('Y-m-d 00:00:00') : $start, $this->timezone);
        $this->end = !empty($end) ? new DateTime($end instanceof DateTime ? $end->format('Y-m-d 00:00:00') : $end, $this->timezone) : null;
        //Difference in days between Start and End dates
        $diffdays = $this->start->diff($this->end, true)->days;
        //Difference in days between Start and Today dates
        $diffTodayDays = $this->start->diff($this->today, true)->days;
        //Previous interval is the same period in the past
        $this->prevInterval = new \DateInterval('P' . ($diffdays + 1) . 'D');
        if ($diffdays < 2 && $diffTodayDays < 14) {
            $this->interval = '1 hour';
        } else {
            $this->interval = '1 day';
        }
        $this->prevStart = clone $this->start;
        $this->prevStart->sub($this->prevInterval);
        $this->wholePeriodPerviousEnd = clone $this->start;
        $this->wholePeriodPerviousEnd->modify('-1 day');
        $this->prevEnd = clone $this->prevStart;
        $this->prevEnd->add(new \DateInterval('P' . $this->start->diff(min($this->end, $this->today), true)->days . 'D'));
        $endoftheday = new \DateInterval('PT23H59M59S');
        $this->end->add($endoftheday);
        $this->prevEnd->add($endoftheday);
        $this->wholePeriodPerviousEnd->add($endoftheday);
        if (!$this->di) {
            $this->di = \DateInterval::createFromDateString($this->interval);
        }
        $this->dt = clone $this->start;
    }
ChartDailyIterator