Resets the date to end of the month and time to 23:59:59.999999

@example
```
echo Carbon::parse('2018-07-25 12:45:16')->endOfMonth();
```

@return static|CarbonInterface
435571
public function endOfMonth()
    {
        return $this->setDate($this->year, $this->month, $this->daysInMonth)->endOfDay();
    }
1310518
protected function generate()
    {
        if ($this->subperiodsProcessed) {
            return;
        }

        $this->loadAllFromCache();

        if ($this->subperiodsProcessed) {
            return;
        }

        parent::generate();

        if (preg_match('/(last|previous)([0-9]*)/', $this->strDate, $regs)) {
            $lastN = $regs[2];
            $lastOrPrevious = $regs[1];
            if (!is_null($this->defaultEndDate)) {
                $defaultEndDate = $this->defaultEndDate;
            } else {
                $defaultEndDate = $this->today;
            }

            $period = $this->strPeriod;
            if ($period == 'range') {
                $period = 'day';
            }

            if ($lastOrPrevious == 'last') {
                $endDate = $defaultEndDate;
            } elseif ($lastOrPrevious == 'previous') {
                if ('month' == $period) {
                    $endDate = $defaultEndDate->subMonth(1);
                } else {
                    $endDate = $defaultEndDate->subPeriod(1, $period);
                }
            }

            $lastN = $this->getMaxN($lastN);

            // last1 means only one result ; last2 means 2 results so we remove only 1 to the days/weeks/etc
            $lastN--;
            if ($lastN < 0) {
                $lastN = 0;
            }

            $startDate = $endDate->addPeriod(-1 * $lastN, $period);
        } elseif ($dateRange = Range::parseDateRange($this->strDate)) {
            $strDateStart = $dateRange[1];
            $strDateEnd = $dateRange[2];
            $startDate = Date::factory($strDateStart);

            // we set the timezone in the Date object only if the date is relative eg. 'today', 'yesterday', 'now'
            $timezone = null;
            if (strpos($strDateEnd, '-') === false) {
                $timezone = $this->timezone;
            }
            $endDate = Date::factory($strDateEnd, $timezone);
        } else {
            throw new Exception($this->translator->translate('General_ExceptionInvalidDateRange', array($this->strDate, ' \'lastN\', \'previousN\', \'YYYY-MM-DD,YYYY-MM-DD\'')));
        }

        if ($this->strPeriod != 'range') {
            $this->fillArraySubPeriods($startDate, $endDate, $this->strPeriod);
            $this->cacheAll();
            return;
        }

        $this->processOptimalSubperiods($startDate, $endDate);
        // When period=range, we want End Date to be the actual specified end date,
        // rather than the end of the month / week / whatever is used for processing this range
        $this->endDate = $endDate;
        $this->cacheAll();
    }
424428
public function getDtEnd()
    {
        if (!$this->valid()) {
            return;
        }
        $end = clone $this->currentDate;

        return $end->modify('+'.$this->eventDuration.' seconds');
    }
1197405
public function local(): Carbon
    {
        $locale   = app(LocaleInterface::class)->code();
        $timezone = Auth::user()->getPreference('TIMEZONE', Site::getPreference('TIMEZONE', 'UTC'));

        return $this->locale($locale)->setTimezone($timezone);
    }
185254
public function endDialog()
    {
        $this->logger->info('Initialize END dialog message');

        $endMsg = new Message(
            $this->bankCode,
            $this->username,
            $this->pin,
            $this->systemId,
            $this->dialogId,
            $this->messageNumber,
            array(
                new HKEND(3, $this->dialogId)
            )
        );

        $this->logger->debug('Sending END message: ' . (string) $endMsg);
        $response = $this->sendMessage($endMsg);
        $this->logger->debug('Got END response: ' . $response->rawResponse);

        $this->logger->info('Resetting dialog ID and message number count');
        $this->dialogId = 0;
        $this->messageNumber = 1;

        return $response->rawResponse;
    }
525577
def _end_of_month(self):
        
        return self.set(self.year, self.month, self.days_in_month, 23, 59, 59, 999999)
534115
public function withDateAtEndOfMonth() : self
    {
        $instance = $this->withDateAtStartOfMonth();
        
        $instance->date->modify('+1 month');
        $instance->date->modify('-1 day');
        
        return $instance;
    }
294210
public function end()
    {
        $endTime = microtime(true);
        $this->value = (int) round(($endTime - $this->startTime) * self::MILLISECONDS_IN_A_SECOND);

        return $this;
    }
701655
public function getFormattedExpirationDate()
    {
        $date = $this->model->getExpirationDate();

        if ($date instanceof Carbon) {
            $isFuture   = $date->isFuture();
            $translated = $isFuture ? $date->diffForHumans(null, true) : $date->diffForHumans();

            if ($isFuture) {
                $translated = 'in ' . $translated;
            }

            return $translated;
        }

        return '---';
    }
1033935
public function startOfQuarter()
    {
        $month = ($this->quarter - 1) * static::MONTHS_PER_QUARTER + 1;

        return $this->setDate($this->year, $month, 1)->startOfDay();
    }
475778
public function getFinishAtAttribute()
    {
        if (array_get($this->attributes, 'finish_at') !== null) {
            return Carbon::parse($this->attributes['finish_at']);
        }

        if (is_numeric($this->duration)) {
            return $this->start_at->addMinutes($this->duration);
        }

        return $this->start_at;
    }
575457
public function loadLastRunTime()
	{
		$date = NULL;
		$filepath = $this->buildFilePath();
		if (file_exists($filepath)) {
			$date = file_get_contents($filepath);
			$date = DateTime::createFromFormat(self::DATETIME_FORMAT, $date);
		}

		return $date ? $date : NULL;
	}
551091
public function calendar($date)
    {
        $events = $this->eventRepository->all();
        $dateArray = explode('-', $date);
        $daysInMonth = Carbon::create($dateArray[0], $dateArray[1], $dateArray[2])->daysInMonth;

        $eventsByDate = [];

        foreach (range(1, $daysInMonth) as $day) {
            $date = $dateArray[0].'-'.$dateArray[1].'-'.sprintf('%02d', $day);
            foreach ($events as $event) {
                $startDate = explode('-', $event->start_date);
                $endDate = explode('-', $event->end_date);
                $first = Carbon::create($startDate[0], $startDate[1], $startDate[2]);
                $second = Carbon::create($endDate[0], $endDate[1], $endDate[2]);
                if (Carbon::create($dateArray[0], $dateArray[1], sprintf('%02d', $day))->between($first, $second)) {
                    $eventsByDate[$date][] = $event;
                }
            }
        }

        return $eventsByDate;
    }
1236541
public function lastChangeTimestamp(): Carbon
    {
        /** @var Fact|null $chan */
        $chan = $this->facts(['CHAN'])->first();

        if ($chan instanceof Fact) {
            // The record does have a CHAN event
            $d = $chan->date()->minimumDate();

            if (preg_match('/\n3 TIME (\d\d):(\d\d):(\d\d)/', $chan->gedcom(), $match)) {
                return Carbon::create($d->year(), $d->month(), $d->day(), (int) $match[1], (int) $match[2], (int) $match[3]);
            }

            if (preg_match('/\n3 TIME (\d\d):(\d\d)/', $chan->gedcom(), $match)) {
                return Carbon::create($d->year(), $d->month(), $d->day(), (int) $match[1], (int) $match[2]);
            }

            return Carbon::create($d->year(), $d->month(), $d->day());
        }

        // The record does not have a CHAN event
        return Carbon::createFromTimestamp(0);
    }
984115
public function setDateEnd(\DateTime $date_end = null)
    {
        $this->date_end = $date_end ? clone $date_end : null;

        return $this;
    }
1049631
public static function thisWeek()
    {
        $start = CarbonDate::today();
        $end = CarbonDate::tomorrow();
        if ($start->dayOfWeek !== CarbonDate::MONDAY) {
            $start->modify('last monday');
        }

        return new static($start, $end);
    }
1125566
public function getDefaultMonth()
    {
        $result = null;

        $keys = array_keys($this->getMonths());
        if (count($keys) >= 2) {
            $result = (string)$keys[1];
        }

        return $result;
    }