Calendar.

@param string $date

@return Response
762464
public function calendar($date = null)
    {
        if (is_null($date)) {
            $date = date('Y-m-d');
        }

        $events = $this->service->calendar($date);
        $calendar = $this->service->generate($date);

        if (empty($calendar)) {
            abort(404);
        }

        return view('cms-frontend::events.calendar')
            ->with('events', $events)
            ->with('calendar', $calendar);
    }
273103
public static function date2sql($date)
    {
        $dt = new Datetime();
        
        return ($dt->set_date($date)) ? $dt->toSql() : false;
    }
768347
private function getLogOrFail($date)
    {
        try {
            return $this->viewer->get($date);
        } catch (Exception $e) {
            return abort(404, $e->getMessage());
        }
    }
502388
public static function date($date)
    {
        $d = explode('/', date('j/n/Y', strtotime($date)));
        if ($d[0] == '1') {
            $d[0] .= 'º';
        }
        $d[1] = self::MONTHS[$d[1] - 1];
        return implode(' de ', $d);
    }
490846
private function getLogOrFail($date)
    {
        try {
            return $this->logViewer->get($date);
        } catch (LogNotFound $e) {
            return abort(404, $e->getMessage());
        }
    }
45384
public static Calendar getDateCeil(Date date) {
        Calendar cal = new GregorianCalendar();
        cal.setTime(date);
        return new GregorianCalendar(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH));
    }
710640
static function fromDate($date = false)
    {
        $format = count(explode(" ", $date)) > 1 ? Settings\DefaultDateSettings::$defaultDateTimeFromat : Settings\DefaultDateSettings::$defaultDateFromat;
        return ($date) ? static::createFromFormat($format, $date) : new self();
    }
1342484
public function toDateTime($date)
    {
        if ($date instanceof \DateTimeInterface) {
            return $date;
        }

        if (preg_match('/^(\d{4})-(\d{1,2})-(\d{1,2})$/', $date)) {
            return \DateTime::createFromFormat('Y-m-d', $date);
        }

        return \DateTime::createFromFormat($this->db->getQuery(true)->getDateFormat(), $date);
    }
241906
public function set_date($date = null)
    {
        if (is_null($date)) {
            return $this->set_timestamp(time());
        }
        elseif (is_numeric($date)) {
            return $this->set_timestamp($date);
        }
        elseif (is_a($date, self::class)) {
            /** @var Datetime $date */
            return $this->set_date($date->format());
        }
        elseif (preg_match(self::REGEX_SQL, $date, $dateSplitted)) {
            if (\checkdate($dateSplitted['M'], $dateSplitted['D'], $dateSplitted['Y'])) {
                $h = (array_key_exists('h', $dateSplitted) && is_numeric($dateSplitted['h'])) ? $dateSplitted['h'] : 0;
                $m = (array_key_exists('m', $dateSplitted) && is_numeric($dateSplitted['m'])) ? $dateSplitted['m'] : 0;
                $s = (array_key_exists('s', $dateSplitted) && is_numeric($dateSplitted['s'])) ? $dateSplitted['s'] : 0;
    
                $mkt = mktime($h, $m, $s, $dateSplitted['M'], $dateSplitted['D'], $dateSplitted['Y']);
                $this->set_date($mkt);
                return $this;
            }
            else {
                return false;
            }
        }
        elseif (preg_match(self::REGEX_STR, $date, $dateSplitted)) {
            if (\checkdate($dateSplitted['M'], $dateSplitted['D'], $dateSplitted['Y'])) {
                $h = (array_key_exists('h', $dateSplitted) && is_numeric($dateSplitted['h'])) ? $dateSplitted['h'] : 0;
                $m = (array_key_exists('m', $dateSplitted) && is_numeric($dateSplitted['m'])) ? $dateSplitted['m'] : 0;
                $s = (array_key_exists('s', $dateSplitted) && is_numeric($dateSplitted['s'])) ? $dateSplitted['s'] : 0;
                
                $mkt = mktime($h, $m, $s, $dateSplitted['M'], $dateSplitted['D'], $dateSplitted['Y']);
                $this->set_date($mkt);
                
                return $this;
            }
            else {
                return false;
            }
        }
        elseif (preg_match(self::REGEX_SEM, $date, $dateSplitted)) {
            $baseDt = new \DateTime();
            $baseDt->setISOdate($dateSplitted['Y'], $dateSplitted['S']);
            return $this->set_date($baseDt->getTimestamp());
        }
        
        return false;
    }
1347866
public function date($date, $verbosity = self::SHORT)
    {
        return $this->toDateTime($date)->format($this->get('date')[$verbosity]);
    }
1075940
public function toDate($date)
	{
		$this->current = (is_string($date) ? new \DateTime($date, self::$utc) : $date);
	}
1303430
final public static function cloneDateTime($date)
    {
        try {
            $result = new \DateTimeImmutable();
            return $result->setTimezone($date->getTimezone())->setTimestamp($date->getTimestamp());
        } catch (\Exception $e) {
            return null;
        }
    }
166149
protected function date_format($date)
    {
        if (empty($date)) {
            return null;
        }

        if (!is_object($date) || !is_a($date, 'DateTime')) {
            try {
                $timestamp = rcube_utils::strtotime($date);
                $date      = new DateTime("@".$timestamp);
            }
            catch (Exception $e) {
                return null;
            }
        }

        return $date->format('d-M-Y H:i:s O');
    }
861342
public function translate($date): Date
    {
        $handle = Date::castFrom($date)->handle();
        $handle->setTimezone($this->timeZone);
        return new Date($handle);
    }
734661
public static function formatDate($date)
    {
        $format = DateTime::ATOM;
        if ($date instanceof DateTime) {
            $d = $date->format($format);
        } elseif (is_numeric($date)) {
            $d = date($format, $date);
        } else {
            $d = (string) $date;
        }
        return $d;
    }
680803
public function dateTo(string $date): Date
    {
        $dates = explode('-', $date);
        if (count($dates) != 3) {
            throw new \InvalidArgumentException(
                    'Given date "' . $date . '" does not follow required format YYYY-MM-DD'
            );
        }

        list($year, $month, $day) = $dates;
        if (!ctype_digit($year)) {
            throw new \InvalidArgumentException(
                    'Given value ' . $year . ' for year not suitable for changing the date.'
            );
        }

        if (!ctype_digit($month) || 1 > $month || 12 < $month) {
            throw new \InvalidArgumentException(
                    'Given value ' . $month . ' for month not suitable for changing the date.'
            );
        }

        if (!ctype_digit($day) || 1 > $day || 31 < $day) {
            throw new \InvalidArgumentException(
                    'Given value ' . $day . ' for day not suitable for changing the date.'
            );
        }

        return $this->createNewDateWithExistingTime((int) $year, (int) $month, (int) $day);
    }
545502
public function formatDate($date)
    {
        // Get format
        $format = 'date_format';
        if ($this->get('time') === 'yes') {
            $format = 'datetime_format';
        }
        return DateTimeObj::format($date, DateTimeObj::getSetting($format));
    }