Validates the input with the supplied format and
converts the input to a TimezonedDateTimeRange instance.

@see Dms\Common\Structure\DateTime\TimezonedDateTimeRange

@param string $format

@return FieldBuilderBase
344460
public function dateTimeWithTimezoneRange(string $format = TimezonedDateTime::DISPLAY_FORMAT) : FieldBuilderBase
    {
        return $this->field->type(new TimezonedDateTimeRangeType($format));
    }
411735
public static function createFromFormat($format, $time, $tz = null)
    {
        if ($tz !== null) {
            $dt = parent::createFromFormat($format, $time, static::safeCreateDateTimeZone($tz));
        } else {
            $dt = parent::createFromFormat($format, $time);
        }

        if ($dt instanceof DateTimeInterface) {
            return static::instance($dt);
        }

        $errors = static::getLastErrors();
        throw new InvalidArgumentException(implode(PHP_EOL, $errors['errors']));
    }
449248
protected static function dateFormatter($dateTime, $format)
    {
        if (is_numeric($dateTime)) {
            return gmdate($format, (int) $dateTime);
        }

        if (is_string($dateTime)) {
            $dateTime = new \DateTime($dateTime);
        }

        if ($dateTime instanceof \DateTime) {
            return $dateTime->setTimezone(self::getUtcTimeZone())->format($format);
        }

        throw new InvalidArgumentException('Date/Time values must be either a string, integer, or DateTime object');
    }
638358
public static function createFromFormat( $format, $time, $timezone = null ) {

		/** @var \DateTimeInterface $created */
		$created = empty( $timezone ) ?
			parent::createFromFormat( $format, $time ) :
			parent::createFromFormat( $format, $time, $timezone );

		if ( false === $created ) {
			return false;
		}

		$wp_date_time = new static( '@' . $created->getTimestamp() );

		return $wp_date_time->setTimezone( $created->getTimezone() );
	}
356630
public function format($format)
    {
        if(Format::exist($format))
            $this->format = Format::get($format);
        else
            Format::invalidType();

        return $this;
    }
439239
public static function validate($format, $timeString)
	{
		$time = DateTime::createFromFormat($format, $timeString);

		return ($time !== FALSE) && ($timeString === $time->format($format));
	}
1195047
public function timeAgo($time = null, $format = null) {
		if (empty($time)) {
			$time = time();
		}
		if (empty($format)) {
			$format = '%x %X';
		}

		$result = $this->Html->tag(
			'time',
			$this->Time->i18nFormat($time, $format),
			[
				'data-toggle' => 'timeago',
				'datetime' => date('c', $this->Time->fromString($time)),
				'class' => 'help'
			]
		);

		return $result;
	}
535962
public function format($format)
    {
        $format = preg_replace_callback('/(?<!\\\\)[DlFM]/', array($this, '_translate'), $format);
        return $this->_date->format($format);
    }
734268
public static function formatOther($timestamp, $format = 'eeee')
    {
        $instance=self::$_instance;
        $fmt=new IntlDateFormatter($instance->_currentLocale, 0, 0);
        $fmt->setPattern($format);
        return $fmt->format($timestamp);
    }
455054
public static function createDateTime(string $name, string $format = 'c'): NormalizationFieldMappingBuilderInterface
    {
        $self = new self($name);
        $self->fieldNormalizer = new DateTimeFieldNormalizer(new PropertyAccessor($name), $format);

        return $self;
    }
58036
public function formatTZ($format)
    {
        $out = '';

        switch ($format) {
            case self::TZ_ID:
                $out = $this->format('e');
                break;

            case self::TZ_SHORT:
            case self::TZ_LONG:
                $id = $this->format('e');
                $abbreviations = self::getTimeZoneAbbreviations();
                if (
                    isset($abbreviations[$id]) &&
                    isset($abbreviations[$id]['st'])
                ) {
                    $out = $abbreviations[$id]['st'];
                }
                break;

            case self::TZ_DST_SHORT:
            case self::TZ_DST_LONG:
                $id = $this->format('e');
                $abbreviations = self::getTimeZoneAbbreviations();
                if (isset($abbreviations[$id])) {
                    if (isset($abbreviations[$id]['dt'])) {
                        $out = $abbreviations[$id]['dt'];
                    } else {
                        $out = $abbreviations[$id]['st'];
                    }
                }
                break;

            case self::TZ_CURRENT_SHORT:
            case self::TZ_CURRENT_LONG:
                $out = $this->format('T');
                break;

            case self::TZ_COMBINED:
                $out = array();
                $id = $this->format('e');
                $abbreviations = self::getTimeZoneAbbreviations();
                if (isset($abbreviations[$id])) {
                    if (isset($abbreviations[$id]['st'])) {
                        $out[] = $abbreviations[$id]['st'];
                    }
                    if (isset($abbreviations[$id]['dt'])) {
                        $out[] = $abbreviations[$id]['dt'];
                    }
                }
                $out = implode('/', $out);
                break;
        }

        return $out;
    }
653170
public static function validateDateFormat($format)
    {
        $format = str_replace(array_keys(static::$_map['date']), '', $format); // remove placeholders
        $format = preg_replace("/'(.*)'/", '', $format); // remove literals
        $format = preg_replace('/[^a-z]/i', '', $format);
        $format = trim($format);

        return empty($format);
    }
832242
public static function createFromFormat($format, $date, $tz = null) {
        
        if ($tz !== null) {
            $tz = static::safeCreateDateTimeZone($tz);
        }
        
        $instance = new static($tz);
        
        $instance->parseFormat($format, $date);
        
        return $instance;
    }
1161388
public function format($format) {

		if(false === is_string($format)) {
			return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($format)), E_USER_ERROR);
		}

		$this -> format = $format;

		return $this;
	}
90845
private function parse_format($format) {

		$format = strtoupper($format);
		$format = str_replace('?', '*', $format);
		$parts  = explode(' ', $format);
		$count  = count($parts);

		if($count < 5 or $count > 6) throw new \InvalidArgumentException('Invalid Cron Format expression provided');

		return array(
			'minute' => new Field_Minute($parts[0]),
			'hour'   => new Field_Hour($parts[1]),
			'dom'    => new Field_DayOfMonth($parts[2]),
			'month'  => new Field_Month($parts[3]),
			'dow'    => new Field_DayOfWeek($parts[4]),
			'year'   => new Field_Year($count === 6 ? $parts[5] : '*'),
		);

	}
87695
public static function normalizeFormat($format)
    {
        static $datesPatterns = null;
        static $timesPatterns = null;

        if ($datesPatterns === null || $timesPatterns === null) {
            $datesPatterns = '/(' . implode('|', array_keys(static::$_map['date'])) . ')/';
            $timesPatterns = '/(' . implode('|', array_keys(static::$_map['time'])) . ')/';
        }

        $format = trim($format);
        $format = preg_replace("/'([^']+)'/", '', $format); // remove quotes
        $format = preg_replace('/\s{2,}/', ' ', $format); // remove double spaces
        $format = trim($format);
        list($dateFormat, $timeFormat) = explode(' ', "{$format} ");

        // normalize formats
        $dateFormat = preg_replace_callback($datesPatterns, function ($matches) {
            return static::$_map['date'][$matches[1]];
        }, $dateFormat);

        $timeFormat = preg_replace_callback($timesPatterns, function ($matches) {
            return static::$_map['time'][$matches[1]];
        }, $timeFormat);

        $format = trim($dateFormat . ' ' . $timeFormat);

        return $format;
    }
991340
public function create($format, $time)
    {
        return Date::createFromFormat($format, $time, $this->cachetTimezone)->setTimezone($this->appTimezone);
    }