Adjusts a date that has rolled over back to the previous month; setting the day
to the last day of the previous month; time values are maintained.

@param Carbon $date
@param Carbon $original_date

@return \DateTime
768873
protected function refactorRolledOverDate(Carbon $date, Carbon $original_date)
    {
        return $date
            ->subMonth()
            ->endOfMonth()
            ->setTime($original_date->hour, $original_date->minute, $original_date->second);
    }
1323294
public function setDate($date, $diff = false) {
        $dateTemp = str_replace('/', '-', $date);
        $formatedDate = date($this->dateFormat, strtotime($dateTemp));
        list($year, $month, $day) = explode("-", $formatedDate);
        if ($diff) {
            $this->dateTimeDiff = null;
            $this->dateTimeDiff = new \DateTime();
            $this->dateTimeDiff->setDate($year, $month, $day);
        } else {
            $this->dateTime = null;
            $this->dateTime = new \DateTime();
            $this->dateTime->setDate($year, $month, $day);
        }
        return $this;
    }
840893
protected function recalculate()
    {
        $adjusted = (new Carbon($this->date))->addDays($this->adjustment);

        $julian = Converter::gregorianToJulian($adjusted->year, $adjusted->month, $adjusted->day);

        $hijri = Converter::julianToHijri($julian);

        $this->julianDay = $julian;
        $this->day = $hijri->day;
        $this->month = $hijri->month;
        $this->day = $hijri->day;

        return $this->fillValuesArray();
    }
504192
public function diffAsCarbonInterval($date = null, $absolute = true)
    {
        return CarbonInterval::instance($this->diff($this->resolveCarbon($date), $absolute));
    }
1189151
public function setLastModified(\DateTime $date = null): self
    {
        if (null === $date) {
            $this->header->remove('Last-Modified');
        } else {
            $date = clone $date;
            $date->setTimezone(new \DateTimeZone('UTC'));
            $this->header->set('Last-Modified', $date->format('D, d M Y H:i:s') . ' GMT');
        }

        return $this;
    }
205096
public Date adjustDate(final Date startDate, final int increment, final NonWorkingDayChecker<Date> checker) {
        final Calendar cal = Utils.getCal(startDate);

        while (checker.isNonWorkingDay(cal.getTime())) {
            if (increment < 0) {
                cal.add(Calendar.DAY_OF_MONTH, -1);
            } else {
                cal.add(Calendar.DAY_OF_MONTH, 1);
            }
        }

        return cal.getTime();
    }
800473
public function diffInRealMicroseconds($date = null, $absolute = true)
    {
        /** @var CarbonInterface $date */
        $date = $this->resolveCarbon($date);
        $value = ($date->timestamp - $this->timestamp) * static::MICROSECONDS_PER_SECOND +
            $date->micro - $this->micro;

        return $absolute ? abs($value) : $value;
    }
888356
protected function prepareForReturn(CarbonInterface $date)
    {
        $date = call_user_func([$this->dateClass, 'make'], $date);

        if ($this->timezone) {
            $date = $date->setTimezone($this->timezone);
        }

        return $date;
    }
1372403
public function registerModificationDate($date)
    {
        $timestamp = is_numeric($date) ? $date : strtotime($date);
        if ($timestamp > $this->modificationDate) {
            $this->modificationDate = $timestamp;
        }
        return $this;
    }
943065
public static function moveDateTimeToLastDayOfMonth(\DateTime $originalDate) : \DateTime
    {
        $Y = (integer)$originalDate->format("Y");
        $m = (integer)$originalDate->format("m");

        
        // Vai para o primeiro dia do mês corrente...
        $originalDate = self::moveDateTimeToFirstDayOfMonth($originalDate);
        // Adiciona 1 mês
        $originalDate->add(new \DateInterval("P1M"));
        // Retrocede 1 dia
        $originalDate->sub(new \DateInterval('P1D'));

        return $originalDate;
    }
1093519
public function setDateFrom($date)
    {
        $date = static::instance($date);

        $this->setDate($date->year, $date->month, $date->day);

        return $this;
    }
486003
public function get($date, $default = null)
    {
        if (!$this->has($date)) {
            return false;
        }
        return parent::get($date, $default);
    }
881623
public function setCurrentDate()
    {
        $this->defaultValue = Carbon::now()->timezone($this->getTimezone())->format($this->getFormat());

        return $this;
    }
687242
public static function refreshTokensExpireIn(DateTimeInterface $date = null)
    {
        if (is_null($date)) {
            return static::$refreshTokensExpireAt
                            ? Carbon::now()->diff(static::$refreshTokensExpireAt)
                            : new DateInterval('P1Y');
        }

        static::$refreshTokensExpireAt = $date;

        return new static;
    }
695058
protected function convertToSqlDateTime($date)
    {
        if ($date instanceof \DateTime) {
            $date = $this->expr()->literal($date->format(self::SQL_DATE_TIME));
        }

        return $date;
    }
273103
public static function date2sql($date)
    {
        $dt = new Datetime();
        
        return ($dt->set_date($date)) ? $dt->toSql() : false;
    }
971102
protected function getFormatedDate($date)
    {
        if (! is_null($date)) {
            if (! ($date instanceof Carbon)) {
                $date = Carbon::parse($date);
            }

            $date = $date->timezone($this->getTimezone())->format($this->getFormat());
        }

        return $date;
    }