Builds the additional path fragment depending on the date.

@param string|int $date A string compatible with `strtotime` or a Unix timestamp.

@return string The relative path with the date path appended, if needed.
186108
protected function buildDateFrag($date)
    {
        $timestamp = is_numeric($date) ? $date : strtotime($date);
        $Y = date('Y', $timestamp);
        $m = date('m', $timestamp);
        $dateFrag = $Y . DIRECTORY_SEPARATOR . $m;

        return $dateFrag;
    }
1169297
public function date($date=null)
    {
        if(is_null($date)) {
            $date = $this->created_at;
        }
        return String::date($date);
    }
1214274
private function getPicturePaths($date)
    {
        $basePath    = $this->options['store_path'].$date;
        $baseUrl     = $this->options['base_url'].$date;
        $thumbSuffix = '.thumb.jpg';

        return [
            'json_path'      => $basePath.'.json',
            'thumbnail_path' => $basePath.$thumbSuffix,
            'thumbnail_url'  => $baseUrl.$thumbSuffix,
        ];
    }
709889
protected function valueToDateTime($date)
    {
        if (!$date instanceof \DateTime) {
            $date = is_int($date) ? \DateTime::createFromFormat('U', $date) : new \DateTime((string)$date);
        }
        
        return $date;
    }
1357386
public static function strtotime($date, $timezone = null)
    {
        $date   = self::clean_datestr($date);
        $tzname = $timezone ? ' ' . $timezone->getName() : '';

        // unix timestamp
        if (is_numeric($date)) {
            return (int) $date;
        }

        // It can be very slow when provided string is not a date and very long
        if (strlen($date) > 128) {
            $date = substr($date, 0, 128);
        }

        // if date parsing fails, we have a date in non-rfc format.
        // remove token from the end and try again
        while (($ts = @strtotime($date . $tzname)) === false || $ts < 0) {
            if (($pos = strrpos($date, ' ')) === false) {
                break;
            }

            $date = rtrim(substr($date, 0, $pos));
        }

        return (int) $ts;
    }
195360
public function read($date)
    {
        try {
            $path = $this->getLogPath($date);

            return $this->filesystem->get($path);
        } catch (Exception $e) {
            Log::emergency($e);
            throw new Exception($e->getMessage());
        }
    }
1338813
private static function cast(Date $date = null)
	{
		if (!is_null($date))
		{
			$date = new DateTime($date);
		}

		return $date;
	}
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);
    }
1036568
protected function _date($date = null) {
		$timeAgoInWords = $date ? $this->Time->timeAgoInWords($date, array('format' => Configure::read('Task.dateFormat'))) : $this->_none();
		return $this->_isCli ? $timeAgoInWords : $this->Html->tag('span', $timeAgoInWords, array('title' => $date instanceof DateTime ? $date->format(Configure::read('Task.dateFormat')) : $date));
	}
535651
static protected function regex($date)
    {
      if(!preg_match('/^' . self::PATTERN . '$/', $date, $matches))
        throw new InvalidArgumentException(__METHOD__ . '; Invalid date, no match with pattern (' . $date . ')');
        
      return $matches;
    }
1017853
public function getStatementForDate($date)
    {
        if (is_string($date)) {
            $date = new \DateTime($date);
        }

        foreach ($this->statements as $stmt) {
            if ($stmt->getDate() == $date) {
                return $stmt;
            }
        }

        return null;
    }
26240
public function date_strtotime($date)
	{
		$strtotime = strtotime($date);
		if ($strtotime === -1 || $strtotime === false)
		{
			return false;
		}
		else
		{
			return $strtotime;
		}
	}
768347
private function getLogOrFail($date)
    {
        try {
            return $this->viewer->get($date);
        } catch (Exception $e) {
            return abort(404, $e->getMessage());
        }
    }
1280558
protected function _formatDate($date)
    {
        $clearDate = trim($date, '\'" ');
        //brak daty, pusty zwrot
        if (!$clearDate || $clearDate == 'false') {
            return;
        }
        return date($this->getFormat(), strtotime($clearDate));
    }
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;
    }
404443
public function read($date)
    {
        try {
            $log = $this->filesystem->get(
                $this->getLogPath($date)
            );
        }
        catch (\Exception $e) {
            throw new FilesystemException($e->getMessage());
        }

        return $log;
    }
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;
    }