Returns either the close date "Friday 15h30", or a calendar date "10/09/2017" is farthest than 7 days from now.

@param Carbon|\DateTimeInterface|string|null $referenceTime
@param array                                 $formats

@return string
483502
public function calendar($referenceTime = null, array $formats = [])
    {
        /** @var CarbonInterface $current */
        $current = $this->copy()->startOfDay();
        /** @var CarbonInterface $other */
        $other = $this->resolveCarbon($referenceTime)->copy()->setTimezone($this->getTimezone())->startOfDay();
        $diff = $other->diffInDays($current, false);
        $format = $diff < -6 ? 'sameElse' : (
            $diff < -1 ? 'lastWeek' : (
                $diff < 0 ? 'lastDay' : (
                    $diff < 1 ? 'sameDay' : (
                        $diff < 2 ? 'nextDay' : (
                            $diff < 7 ? 'nextWeek' : 'sameElse'
                        )
                    )
                )
            )
        );
        $format = array_merge($this->getCalendarFormats(), $formats)[$format];
        if ($format instanceof Closure) {
            $format = $format($current, $other) ?? '';
        }

        return $this->isoFormat(strval($format));
    }
717374
public function date($date, $format = null)
    {
        if ($this->isEmptyDate($date)) {
            return '';
        }

        $isLocalizerFormat = in_array($format, [Localizer::SHORT, Localizer::LONG, Localizer::VERBOSE]);

        if ($format && !$isLocalizerFormat) {
            return $this->toDateTime($date)->format($format);
        }

        if (!$this->localizer) {
            return $this->toDateTime($date)->format('Y-m-d');
        }

        return $this->localizer->date($date, $format ?: Localizer::SHORT);
    }
864895
public function getEnqueuedDate($format = null)
    {
        $node = $this->getFirst('//epp:epp/epp:response/epp:msgQ/epp:qDate');
        if ($node === null) {
            return null;
        }

        if ($format === null) {
            return $node->nodeValue;
        }

        return date_create_from_format($format, $node->nodeValue);
    }
283977
public function getDateSunday($format = 'Y-m-d')
    {
        $weekDay = 7 - $this->format('N');
        $time = $this->getTimestamp();
        if ($weekDay) {
            $time += $weekDay * 24 * 3600;
        }
        return date($format, $time);
    }
323899
public function getDate($date = null, $format = 'Y-m-d H:i:s')
    {
        if (strlen($date) < 0) {
            $date = date('d-m-Y H:i:s');
        }

        $timeStamp = new DateTime($date);
        return $timeStamp->format($format);
    }
1363057
public static function selectDays($format = '%02d'): array
    {
        $days = [];
        for ($i = 1; $i <= 31; $i++) {
            $val = sprintf($format, $i);
            $label = $i;
            $days[$val] = $label;
        }
        return $days;
    }
563313
public function getServerDate($format = null)
    {
        $node = $this->getFirst('//epp:epp/epp:greeting/epp:svDate');
        if ($format === null) {
            return $node->nodeValue;
        }

        return date_create_from_format($format, $node->nodeValue);
    }
278250
public function date($timestamp = null, $full = true)
    {
        if (!isset($timestamp)) {
            $timestamp = GC_TIME;
        }

        if ($full) {
            $format = $this->config->get('date_full_format', 'd.m.Y H:i');
        } else {
            $format = $this->config->get('date_short_format', 'd.m.y');
        }

        return date($format, $timestamp);
    }
677607
public static function date($format = "Y-m-d H:i:s", $time = null)
    {
        $time = ($time !== null ? $time : time());

        if (!is_numeric($time)) {
            $time = static::toUnix($time);
        }

        return date($format, $time);
    }
218900
public function getDateMonday($format = 'Y-m-d')
    {
        $weekDay = $this->format('N') - 1;
        $dateTime = clone $this;
        if ($weekDay) {
            $dateTime->add(sprintf('- %d days', $weekDay));
        }
        if ($format) {
            return $dateTime->format($format);
        }
        return $dateTime;
    }
1169868
public function getExpiryDate($format = null)
    {
        $node = $this->getFirst('//epp:epp/epp:response/epp:resData/domain:trnData/domain:exDate');
        if ($node === null) {
            return null;
        }

        if ($format === null) {
            return $node->nodeValue;
        }

        return date_create_from_format($format, $node->nodeValue);
    }
204954
public static function date($format, $time = null, $gm = true)
    {
        if (is_null($time)) {
            $time = self::time();
        }
        if ($gm) {
            return gmdate($format, $time);
        }
        return date($format, $time);
    }
422387
public function getCreateDate($format = null)
    {
        $node = $this->getFirst('//epp:epp/epp:response/epp:resData/contact:creData/contact:crDate');
        if ($format === null) {
            return $node->nodeValue;
        }

        return date_create_from_format($format, $node->nodeValue);
    }
34029
public static function toDbFormatGmt($format = "Y-m-d H:i:s", $timestamp = null)
    {
        if ($timestamp === null) {
            $timestamp = time();
        }
        return gmdate($format, $timestamp);
    }
1355491
public static function datetime($value, $format = 'Y-m-d H:i:s')
    {
        if (empty($value)) {
            return null;    
        }
        
        $datetime = new \DateTime($value);

        return $datetime->format($format);
    }
92525
public function getAsDate($column, $format = null, $default = false)
  {
    $v = $this->get($column, $default);

    return $v ? new DateTime($v, null, $format) : $default;
  }
816959
protected static Date getTime(final Date referenceDate, final Calendar cal) {
        final Date zonedDate = new DateTime(referenceDate);
        zonedDate.setTime(cal.getTime().getTime());
        return zonedDate;
    }