Scalr\Stats\CostAnalytics\Iterator\ChartMonthlyIterator::__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 = 'month';
        $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;
        //Previous period is the previous month started from the the first day of the month
        $this->prevInterval = new \DateInterval('P1M');
        $this->interval = '1 day';
        $this->start = new DateTime($this->start->format('Y-m-01'), $this->timezone);
        $this->end = new DateTime($this->start->format('Y-m-t'), $this->timezone);
        $this->prevStart = clone $this->start;
        $this->prevStart->sub($this->prevInterval);
        $this->wholePeriodPerviousEnd = clone $this->prevStart;
        $this->wholePeriodPerviousEnd->modify('last day of this month');
        $this->determinePrevEnd();
        $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;
    }
ChartMonthlyIterator