Scalr\Stats\CostAnalytics\Iterator\ChartWeeklyIterator::__construct PHP Method

__construct() public method

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 = 'week';
        $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;
        //Week should start from sunday
        if ($this->start->format('w') != 0) {
            $this->start->modify('last sunday');
        }
        $this->prevInterval = new \DateInterval('P7D');
        //Each point
        $this->interval = '1 day';
        $this->end = clone $this->start;
        $this->end->add(new \DateInterval('P6D'));
        $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;
    }
ChartWeeklyIterator