Get current month's days range.

@param  string  $keyFormat
@param  string  $interval

@return array
173750
public static function getCurrentMonthDaysRange($keyFormat = 'Y-m-d', $interval = '1 day')
    {
        $start = Carbon::now()->subMonth(1)->setTime(0, 0);
        $end   = Carbon::now()->setTime(23, 59, 59);

        $range = new Collection;

        /** @var  \Carbon\Carbon  $period */
        foreach (new DatePeriod($start, DateInterval::createFromDateString($interval), $end) as $period) {
            $range->put($period->format($keyFormat), $period);
        }

        return compact('start', 'end', 'range');
    }
170278
protected function getForPeriod($key, \DatePeriod $period)
    {
        $ranges = $this->getRanges($period);

        if (count($ranges) > 0) {
            if (count($ranges) == 1 && !($ranges[0] instanceof DateRange)) {
                return new DateValue($ranges[0], $this->repository->getFor($key, $ranges[0]));
            }

            $values = array();

            /** @var \Krucas\Counter\DateRange $range */
            foreach ($ranges as $range) {
                $values[] = new RangeValue(
                    $range,
                    $this->repository->getForRange($key, $range->getStartDate(), $range->getEndDate())
                );
            }

            return $values;
        }

        return null;
    }
859424
public function getOffsetDates(string $format, int $interval = 30): array
    {
        $dates = [];
        $interval *= 60;

        for ($i=-12*3600; $i <= (12*3600); $i+=$interval) {
            $time = $this->time + $i;
            $dates[$i] = date($format, $time);
        }

        return $dates;
    }
18972
public function date($key, $format = "F j, Y")
    {
        if (is_numeric($this->_params[$key])) {
            return date($format, $this->_params[$key]);
        }

        return date($format, strtotime($this->_params[$key]));
    }
267682
protected function getDateFormatter($dateFormat, $timeFormat, $calendar)
    {
        $datetype = isset($dateFormat) ? $this->getFormat($dateFormat) : null;
        $timetype = isset($timeFormat) ? $this->getFormat($timeFormat) : null;

        $calendarConst = $calendar === 'traditional' ? \IntlDateFormatter::TRADITIONAL : \IntlDateFormatter::GREGORIAN;
        
        $pattern = $this->getDateTimePattern(
            isset($datetype) ? $datetype : $dateFormat,
            isset($timetype) ? $timetype : $timeFormat,
            $calendarConst
        );
        
        return new \IntlDateFormatter(\Locale::getDefault(), $datetype, $timetype, null, $calendarConst, $pattern);
    }
1098675
public function findCalculateDate(Range $interval): array
	{
		$result = [];
		if (!isset($this->isCalculated[(string) $interval])) {
			$this->isCalculated[(string) $interval] = true;

			// dopocita posledni den
			if ($interval->to->format('Y-m-d') >= (new DateTime)->format('Y-m-d')) {
				$last = $this->connection->query('SELECT MAX([datefield]) datefield FROM %table', $this->getTableName())->fetch();
				if ($last) {
					$result[] = $last->datefield;
				}
			}

			// chybejici dny
			$dates = 'SELECT DATE_ADD(DATE(%dt), INTERVAL t4 + t16 + t64 + t256 + t1024 DAY) missingDate 
                    FROM 
                        (SELECT 0 t4    UNION ALL SELECT 1   UNION ALL SELECT 2   UNION ALL SELECT 3  ) t4,
                        (SELECT 0 t16   UNION ALL SELECT 4   UNION ALL SELECT 8   UNION ALL SELECT 12 ) t16,   
                        (SELECT 0 t64   UNION ALL SELECT 16  UNION ALL SELECT 32  UNION ALL SELECT 48 ) t64,      
                        (SELECT 0 t256  UNION ALL SELECT 64  UNION ALL SELECT 128 UNION ALL SELECT 192) t256,     
                        (SELECT 0 t1024 UNION ALL SELECT 256 UNION ALL SELECT 512 UNION ALL SELECT 768) t1024';

			$visits = 'SELECT DATE([datefield]) '
				. 'FROM %table '
				. 'WHERE DATE([datefield]) BETWEEN DATE(%dt) AND DATE(%dt)';

			$calculateDates = $this->connection->query('SELECT DATE([missingDate]) date FROM (' . $dates . ') dates '
				. 'WHERE [missingDate] NOT IN (' . $visits . ') '
				. 'AND [missingDate] <= DATE(%dt)', $interval->from, $this->getTableName(), $interval->from, $interval->to, $interval->to);

			if ($calculateDates) {
				foreach ($calculateDates as $date) {
					$result[] = $date->date;
				}
			}
		}
		return $result;
	}
1246472
private function dateIntervalToIntervalSpec(DateInterval $interval)
    {
        $date = sprintf('%uY%uM%uD', $interval->y, $interval->m, $interval->d);
        $time = sprintf('%uH%uM%uS', $interval->h, $interval->i, $interval->s);

        // build extra spec
        $extra = '';
        if ($interval->invert) {
            $extra .= 'I';
        }

        if ($interval->days) {
            $extra .= $interval->days . 'D';
        }

        if (strlen($extra) > 0) {
            $extra = '-' . $extra;
        }

        return sprintf('P%sT%s%s', $date, $time, $extra);
    }
501676
public function search($interval)
    {
        if (is_null($this->top_node)) {
            return array();
        }

        $result = $this->find_intervals($interval);
        $result = array_values($result);

        usort($result, function (RangeInterface $a, RangeInterface $b) {
            $x = $a->getStart();
            $y = $b->getStart();

            $comparedValue = $this->compare($x, $y);

            if ($comparedValue == 0) {
                $x = $a->getEnd();
                $y = $b->getEnd();
                $comparedValue = $this->compare($x, $y);
            }

            return $comparedValue;
        });

        return $result;
    }
855583
public static function monthRange($everyDay = false)
    {
        return [
            mktime(0, 0, 0, date('m'), 1, date('Y')),
            mktime(23, 59, 59, date('m'), date('t'), date('Y'))
        ];
    }
139190
public function getStartExecutionTime($numberFormat = false, $decimals = 6)
    {
        if ( ! $numberFormat) {
            return $this->startExecutionTime;
        }

        return number_format($this->startExecutionTime, $decimals);
    }
25562
public static function getSecondsFromInterval(DateInterval $interval)
    {
        $map   = [31536000, 2592000, 86400, 3600, 60, 1];
        $parts = explode('.', $interval->format('%y.%m.%d.%h.%i.%s'));
        $value = 0;

        foreach ($parts as $key => $val) {
            $value+= $val * $map[$key];
        }

        return $value;
    }
905678
public function indexOf(Period $interval)
    {
        foreach ($this->intervals as $offset => $period) {
            if ($period->equals($interval)) {
                return $offset;
            }
        }

        return false;
    }
1280369
private long findInterval(final String dateFormat) {

		final long max = TimeUnit.DAYS.toMillis(365);
		final long step = TimeUnit.SECONDS.toMillis(60);

		try {

			final SimpleDateFormat format = new SimpleDateFormat(dateFormat);
			final long initial = format.parse(format.format(3600)).getTime();

			for (long i = initial; i < max; i += step) {

				final long current = format.parse(format.format(i)).getTime();

				if (initial != current) {
					return i - initial;
				}
			}

			return max;

		} catch (ParseException pex) {
			logger.warn("", pex);
		}

		return max;
	}
31127
public function setDateFormat($format = null, $dateIntervalFormat = null)
    {
        if (null !== $format) {
            $this->dateFormats[0] = $format;
        }

        if (null !== $dateIntervalFormat) {
            $this->dateFormats[1] = $dateIntervalFormat;
        }
    }
129602
public function getFormattedDateRangeDate() {

    // Load session instance date range date values.
    $timestamp = $this->get('timestamp')->value;
    $year_start = date('Y', $timestamp);
    $month_day_start = date('M j', $timestamp);
    $timestamp_to = $this->get('timestamp_to')->value;
    $year_to = date('Y', $timestamp_to);
    $month_day_to = date('M j', $timestamp_to);

    // Format date range to eliminate repeated values.
    if ($year_start == $year_to) {
      if (date('M', $timestamp) == date('M', $timestamp_to)) {
        if ($month_day_start == $month_day_to) {
          // M j, Y.
          $formatted_date = "$month_day_start, $year_start";
        }
        else {
          // M j - j, Y.
          $day_to = date('j', $timestamp_to);
          $formatted_date =  "$month_day_start - $day_to, $year_start";
        }
      }
      else {
        // M j - M j, Y.
        $formatted_date =  "$month_day_start - $month_day_to, $year_start";
      }
    }
    else {
      // M j, Y - M j, Y.
      $formatted_date = $month_day_start . ", $year_start - " . $month_day_to . ", $year_to";
    }

    return $formatted_date;
  }
877934
protected function getDatetimeFormat()
    {
        if( $this->interval !== '* * * * *' )
        {
            $interval = $this->interval.' ';
        }
        else
        {
            $interval = ( $this->minute    ?? '*' ) . ' '.
                        ( $this->hour      ?? '*' ) . ' '.
                        ( $this->dayNumber ?? '*' ) . ' '.
                        ( $this->month     ?? '*' ) . ' '.
                        ( $this->day       ?? '*' ) . ' ';
        }

        $this->defaultIntervalVariables();

        return $interval;
    }
708901
public function getDays($total = false)
    {
        return ($total == true) ? $this->getInterval()->days : $this->getInterval()->d;
    }