PHP Трейт Cake\Chronos\Traits\FactoryTrait

Показать файл Открыть проект

Защищенные свойства (Protected)

Свойство Тип Описание
$_lastErrors array Holds the last error generated by createFromFormat

Открытые методы

Метод Описание
create ( integer | null $year = null, integer | null $month = null, integer | null $day = null, integer | null $hour = null, integer | null $minute = null, integer | null $second = null, DateTimeZon\DateTimeZone | string | null $tz = null ) : static Create a new ChronosInterface instance from a specific date and time.
createFromDate ( integer $year = null, integer $month = null, integer $day = null, DateTimeZon\DateTimeZone | string | null $tz = null ) : static Create a ChronosInterface instance from just a date. The time portion is set to now.
createFromFormat ( string $format, string $time, DateTimeZon\DateTimeZone | string | null $tz = null ) : static Create a ChronosInterface instance from a specific format
createFromTime ( integer | null $hour = null, integer | null $minute = null, integer | null $second = null, DateTimeZon\DateTimeZone | string | null $tz = null ) : static Create a ChronosInterface instance from just a time. The date portion is set to today.
createFromTimestamp ( integer $timestamp, DateTimeZon\DateTimeZone | string | null $tz = null ) : static Create a ChronosInterface instance from a timestamp
createFromTimestampUTC ( integer $timestamp ) : static Create a ChronosInterface instance from an UTC timestamp
getLastErrors ( ) : array Returns any errors or warnings that were found during the parsing of the last object created by this class.
instance ( DateTimeInterface $dt ) : static Create a ChronosInterface instance from a DateTimeInterface one
maxValue ( ) : Cake\Chronos\ChronosInterface Create a ChronosInterface instance for the greatest supported date.
minValue ( ) : Cake\Chronos\ChronosInterface Create a ChronosInterface instance for the lowest supported date.
now ( DateTimeZon\DateTimeZone | string | null $tz = null ) : static Get a ChronosInterface instance for the current date and time
parse ( string $time = 'now', DateTimeZon\DateTimeZone | string | null $tz = null ) Create a ChronosInterface instance from a string. This is an alias for the constructor that allows better fluent syntax as it allows you to do ChronosInterface::parse('Monday next week')->fn() rather than (new Chronos('Monday next week'))->fn()
today ( DateTimeZon\DateTimeZone | string | null $tz = null ) : static Create a ChronosInterface instance for today
tomorrow ( DateTimeZon\DateTimeZone | string | null $tz = null ) : static Create a ChronosInterface instance for tomorrow
yesterday ( DateTimeZon\DateTimeZone | string | null $tz = null ) : static Create a ChronosInterface instance for yesterday

Защищенные методы

Метод Описание
safeCreateDateTimeZone ( DateTimeZon\DateTimeZone | string | null $object ) : DateTimeZone Creates a DateTimeZone from a string or a DateTimeZone

Описание методов

create() публичный статический метод

If any of $year, $month or $day are set to null their now() values will be used. If $hour is null it will be set to its now() value and the default values for $minute and $second will be their now() values. If $hour is not null then the default values for $minute and $second will be 0.
public static create ( integer | null $year = null, integer | null $month = null, integer | null $day = null, integer | null $hour = null, integer | null $minute = null, integer | null $second = null, DateTimeZon\DateTimeZone | string | null $tz = null ) : static
$year integer | null The year to create an instance with.
$month integer | null The month to create an instance with.
$day integer | null The day to create an instance with.
$hour integer | null The hour to create an instance with.
$minute integer | null The minute to create an instance with.
$second integer | null The second to create an instance with.
$tz DateTimeZon\DateTimeZone | string | null The DateTimeZone object or timezone name the new instance should use.
Результат static

createFromDate() публичный статический метод

Create a ChronosInterface instance from just a date. The time portion is set to now.
public static createFromDate ( integer $year = null, integer $month = null, integer $day = null, DateTimeZon\DateTimeZone | string | null $tz = null ) : static
$year integer The year to create an instance with.
$month integer The month to create an instance with.
$day integer The day to create an instance with.
$tz DateTimeZon\DateTimeZone | string | null The DateTimeZone object or timezone name the new instance should use.
Результат static

createFromFormat() публичный статический метод

Create a ChronosInterface instance from a specific format
public static createFromFormat ( string $format, string $time, DateTimeZon\DateTimeZone | string | null $tz = null ) : static
$format string The date() compatible format string.
$time string The formatted date string to interpret.
$tz DateTimeZon\DateTimeZone | string | null The DateTimeZone object or timezone name the new instance should use.
Результат static

createFromTime() публичный статический метод

Create a ChronosInterface instance from just a time. The date portion is set to today.
public static createFromTime ( integer | null $hour = null, integer | null $minute = null, integer | null $second = null, DateTimeZon\DateTimeZone | string | null $tz = null ) : static
$hour integer | null The hour to create an instance with.
$minute integer | null The minute to create an instance with.
$second integer | null The second to create an instance with.
$tz DateTimeZon\DateTimeZone | string | null The DateTimeZone object or timezone name the new instance should use.
Результат static

createFromTimestamp() публичный статический метод

Create a ChronosInterface instance from a timestamp
public static createFromTimestamp ( integer $timestamp, DateTimeZon\DateTimeZone | string | null $tz = null ) : static
$timestamp integer The timestamp to create an instance from.
$tz DateTimeZon\DateTimeZone | string | null The DateTimeZone object or timezone name the new instance should use.
Результат static

createFromTimestampUTC() публичный статический метод

Create a ChronosInterface instance from an UTC timestamp
public static createFromTimestampUTC ( integer $timestamp ) : static
$timestamp integer The UTC timestamp to create an instance from.
Результат static

getLastErrors() публичный статический метод

Returns any errors or warnings that were found during the parsing of the last object created by this class.
public static getLastErrors ( ) : array
Результат array

instance() публичный статический метод

Create a ChronosInterface instance from a DateTimeInterface one
public static instance ( DateTimeInterface $dt ) : static
$dt DateTimeInterface The datetime instance to convert.
Результат static

maxValue() публичный статический метод

Create a ChronosInterface instance for the greatest supported date.
public static maxValue ( ) : Cake\Chronos\ChronosInterface
Результат Cake\Chronos\ChronosInterface

minValue() публичный статический метод

Create a ChronosInterface instance for the lowest supported date.
public static minValue ( ) : Cake\Chronos\ChronosInterface
Результат Cake\Chronos\ChronosInterface

now() публичный статический метод

Get a ChronosInterface instance for the current date and time
public static now ( DateTimeZon\DateTimeZone | string | null $tz = null ) : static
$tz DateTimeZon\DateTimeZone | string | null The DateTimeZone object or timezone name.
Результат static

parse() публичный статический метод

Create a ChronosInterface instance from a string. This is an alias for the constructor that allows better fluent syntax as it allows you to do ChronosInterface::parse('Monday next week')->fn() rather than (new Chronos('Monday next week'))->fn()
public static parse ( string $time = 'now', DateTimeZon\DateTimeZone | string | null $tz = null )
$time string The strtotime compatible string to parse
$tz DateTimeZon\DateTimeZone | string | null The DateTimeZone object or timezone name.

safeCreateDateTimeZone() защищенный статический метод

Creates a DateTimeZone from a string or a DateTimeZone
protected static safeCreateDateTimeZone ( DateTimeZon\DateTimeZone | string | null $object ) : DateTimeZone
$object DateTimeZon\DateTimeZone | string | null The value to convert.
Результат DateTimeZone

today() публичный статический метод

Create a ChronosInterface instance for today
public static today ( DateTimeZon\DateTimeZone | string | null $tz = null ) : static
$tz DateTimeZon\DateTimeZone | string | null The timezone to use.
Результат static

tomorrow() публичный статический метод

Create a ChronosInterface instance for tomorrow
public static tomorrow ( DateTimeZon\DateTimeZone | string | null $tz = null ) : static
$tz DateTimeZon\DateTimeZone | string | null The DateTimeZone object or timezone name the new instance should use.
Результат static

yesterday() публичный статический метод

Create a ChronosInterface instance for yesterday
public static yesterday ( DateTimeZon\DateTimeZone | string | null $tz = null ) : static
$tz DateTimeZon\DateTimeZone | string | null The DateTimeZone object or timezone name the new instance should use.
Результат static

Описание свойств

$_lastErrors защищенное статическое свойство

Holds the last error generated by createFromFormat
protected static array $_lastErrors
Результат array