Return final date and time on supplied format.

@param string $pattern pattern of datetime based on ICU standards

@return string

@since 1.0.0
555451
public function asDateTime($pattern = 'yyyy/MM/dd, HH:mm:ss')
    {
        $this->setFinalPattern($this->parsePattern($pattern));

        return $this->getIntlDateFormatter()->format($this->getIntlCalendar());
    }
186354
public function getKeys($pattern = null)
    {
        $keys = $this->get('__stored_keys__', []);
        if (is_null($pattern)) {
            return $keys;
        }

        $matches = [];
        $pattern = $this->_normalizePattern($pattern);
        foreach ($keys as $key) {
            if (preg_match($pattern, $key)) {
                $matches[] = $key;
            }
        }

        return $matches;
    }
721561
public function formatTime($time, $pattern = null, $locale = null, $timezone = null, $timeType = null)
    {
        if ($pattern) {
            return $this->helper->format($time, $pattern, $locale, $timezone);
        }

        return $this->helper->formatTime($time, $locale, $timezone, $timeType);
    }
447516
public function pattern($pattern = null)
        {
            if ($pattern === null) return $this->rulePattern;

            $this->rulePattern = $pattern;

            return $this;
        }
458649
protected function parseFormat($pattern)
	{
		static $formats=array();  // cache
		if(isset($formats[$pattern]))
			return $formats[$pattern];
		$tokens=array();
		$n=strlen($pattern);
		$isLiteral=false;
		$literal='';
		for($i=0;$i<$n;++$i)
		{
			$c=$pattern[$i];
			if($c==="'")
			{
				if($i<$n-1 && $pattern[$i+1]==="'")
				{
					$tokens[]="'";
					$i++;
				}
				elseif($isLiteral)
				{
					$tokens[]=$literal;
					$literal='';
					$isLiteral=false;
				}
				else
				{
					$isLiteral=true;
					$literal='';
				}
			}
			elseif($isLiteral)
				$literal.=$c;
			else
			{
				for($j=$i+1;$j<$n;++$j)
				{
					if($pattern[$j]!==$c)
						break;
				}
				$p=str_repeat($c,$j-$i);
				if(isset(self::$_formatters[$c]))
					$tokens[]=array(self::$_formatters[$c],$p);
				else
					$tokens[]=$p;
				$i=$j-1;
			}
		}
		if($literal!=='')
			$tokens[]=$literal;

		return $formats[$pattern]=$tokens;
	}
375024
protected function assertPattern($pattern)
    {
        if (strlen($pattern) == 0) return null;

        $pattern = '/^'. str_replace('/', '\\/', $pattern). '$/';
        if (@preg_match($pattern, null) === false) {
            throw new DefinitionException("invalid regular expression pattern");
        }

        return $pattern;
    }
25466
public function getLastRead(): \DateTime
    {
        if ($this->caching == false) {
            return \DateTime::createFromFormat("F d Y H:i:s.", date("F d Y H:i:s.", fileatime($this->getAbsoluteFilePath())));
        }

        if ($this->lastRead == null) {
            $this->lastRead = \DateTime::createFromFormat("F d Y H:i:s.", date("F d Y H:i:s.", fileatime($this->getAbsoluteFilePath())));
        }

        return $this->lastRead;
    }
713291
public static String format(final LocalDateTime self, String pattern) {
        return self.format(DateTimeFormatter.ofPattern(pattern));
    }
396337
protected function findFilesInCacheDir($pattern)
    {
        $finder = new Finder();
        
        return $finder
            ->name($pattern)
            ->in($this->getCacheDir())
        ;
    }
910823
public function getPHPTimePattern()
    {
        $isoFormat = Calendar::getTimeFormat('short');
        $result = Calendar::tryConvertIsoToPhpFormat($isoFormat);
        if ($result === null) {
            $result = t(/*i18n: Short time format: see http://www.php.net/manual/en/function.date.php */ 'g.i A');
        }

        return $result;
    }
1340804
protected function formatMinutes($pattern,$date)
	{
		$minutes=$date['minutes'];
		if($pattern==='m')
			return $minutes;
		elseif($pattern==='mm')
			return str_pad($minutes,2,'0',STR_PAD_LEFT);
		else
			throw new CException(Yii::t('yii','The pattern for minutes must be "m" or "mm".'));
	}
244398
public static String formatDate(final Date value, final String pattern)
    {
        return new SimpleDateFormat(pattern, context.get().getLocale()).format(value);
    }
923305
public static function formatRegex($pattern)
    {
        if (strpos($pattern, '/') !== false
            && strpos($pattern, '\\/') === false
        ) {
            $pattern = str_replace('/', '\\/', $pattern);
        }
        return '/' . $pattern . '/';
    }
563164
public static function toString($date, $pattern = "Y-m-d H:i")
    {
        if ($date && is_object($date) && ($date instanceof \MongoDate)) {
            return date($pattern, $date->sec);
        } elseif (is_int($date)) {
            return date($pattern, $date);
        }
    }
615852
protected function getRegExpForPattern(string $pattern) : string
    {
        $patternReplaced = str_replace(['*', '?'], ["\nA\n", "\nQ\n"], $pattern);
        $patternReplaced = preg_quote($patternReplaced, '/');
        $patternReplaced = str_replace(["\nA\n", "\nQ\n"], ['.*', '.'], $patternReplaced);

        return '/^' . $patternReplaced . '$/';
    }
278431
public function getFormatPattern($format)
    {
        switch ($format) {
            case self::DATETIME_FORMAT_LONG:
                return 'EEEE, MMMM d, y HH:mm:ss';

            case self::DATETIME_FORMAT_SHORT:
                return 'MMM d, y HH:mm:ss';

            case self::DATE_FORMAT_LONG:
                return 'EEEE, MMMM d, y';

            case self::DATE_FORMAT_DAY_MONTH:
                return 'E, MMM d';

            case self::DATE_FORMAT_SHORT:
                return 'MMM d, y';

            case self::DATE_FORMAT_MONTH_SHORT:
                return 'MMM y';

            case self::DATE_FORMAT_MONTH_LONG:
                return 'MMMM y';

            case self::DATE_FORMAT_YEAR:
                return 'y';

            case self::TIME_FORMAT:
                return 'HH:mm:ss';
        }

        return $format;
    }
1307851
protected function parseFormat($pattern)
	{
		if(isset($this->_formats[$pattern]))
			return $this->_formats[$pattern];

		$format=array();

		// find out prefix and suffix for positive and negative patterns
		$patterns=explode(';',$pattern);
		$format['positivePrefix']=$format['positiveSuffix']=$format['negativePrefix']=$format['negativeSuffix']='';
		if(preg_match('/^(.*?)[#,\.0]+(.*?)$/',$patterns[0],$matches))
		{
			$format['positivePrefix']=$matches[1];
			$format['positiveSuffix']=$matches[2];
		}

		if(isset($patterns[1]) && preg_match('/^(.*?)[#,\.0]+(.*?)$/',$patterns[1],$matches))  // with a negative pattern
		{
			$format['negativePrefix']=$matches[1];
			$format['negativeSuffix']=$matches[2];
		}
		else
		{
			$format['negativePrefix']=$this->_locale->getNumberSymbol('minusSign').$format['positivePrefix'];
			$format['negativeSuffix']=$format['positiveSuffix'];
		}
		$pat=$patterns[0];

		// find out multiplier
		if(strpos($pat,'%')!==false)
			$format['multiplier']=100;
		elseif(strpos($pat,'‰')!==false)
			$format['multiplier']=1000;
		else
			$format['multiplier']=1;

		// find out things about decimal part
		if(($pos=strpos($pat,'.'))!==false)
		{
			if(($pos2=strrpos($pat,'0'))>$pos)
				$format['decimalDigits']=$pos2-$pos;
			else
				$format['decimalDigits']=0;
			if(($pos3=strrpos($pat,'#'))>=$pos2)
				$format['maxDecimalDigits']=$pos3-$pos;
			else
				$format['maxDecimalDigits']=$format['decimalDigits'];
			$pat=substr($pat,0,$pos);
		}
		else   // no decimal part
		{
			$format['decimalDigits']=0;
			$format['maxDecimalDigits']=0;
		}

		// find out things about integer part
		$p=str_replace(',','',$pat);
		if(($pos=strpos($p,'0'))!==false)
			$format['integerDigits']=strrpos($p,'0')-$pos+1;
		else
			$format['integerDigits']=0;
		// find out group sizes. some patterns may have two different group sizes
		$p=str_replace('#','0',$pat);
		if(($pos=strrpos($pat,','))!==false)
		{
			$format['groupSize1']=strrpos($p,'0')-$pos;
			if(($pos2=strrpos(substr($p,0,$pos),','))!==false)
				$format['groupSize2']=$pos-$pos2-1;
			else
				$format['groupSize2']=0;
		}
		else
			$format['groupSize1']=$format['groupSize2']=0;

		return $this->_formats[$pattern]=$format;
	}