PHP Trait Cake\Chronos\Traits\FactoryTrait

Afficher le fichier Open project: cakephp/chronos

Protected Properties

Свойство Type Description
$_lastErrors array Holds the last error generated by createFromFormat

Méthodes publiques

Méthode Description
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

Méthodes protégées

Méthode Description
safeCreateDateTimeZone ( DateTimeZon\DateTimeZone | string | null $object ) : DateTimeZone Creates a DateTimeZone from a string or a DateTimeZone

Method Details

create() public static méthode

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.
Résultat static

createFromDate() public static méthode

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.
Résultat static

createFromFormat() public static méthode

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.
Résultat static

createFromTime() public static méthode

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.
Résultat static

createFromTimestamp() public static méthode

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.
Résultat static

createFromTimestampUTC() public static méthode

Create a ChronosInterface instance from an UTC timestamp
public static createFromTimestampUTC ( integer $timestamp ) : static
$timestamp integer The UTC timestamp to create an instance from.
Résultat static

getLastErrors() public static méthode

Returns any errors or warnings that were found during the parsing of the last object created by this class.
public static getLastErrors ( ) : array
Résultat array

instance() public static méthode

Create a ChronosInterface instance from a DateTimeInterface one
public static instance ( DateTimeInterface $dt ) : static
$dt DateTimeInterface The datetime instance to convert.
Résultat static

maxValue() public static méthode

Create a ChronosInterface instance for the greatest supported date.
public static maxValue ( ) : Cake\Chronos\ChronosInterface
Résultat Cake\Chronos\ChronosInterface

minValue() public static méthode

Create a ChronosInterface instance for the lowest supported date.
public static minValue ( ) : Cake\Chronos\ChronosInterface
Résultat Cake\Chronos\ChronosInterface

now() public static méthode

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.
Résultat static

parse() public static méthode

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() protected static méthode

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.
Résultat DateTimeZone

today() public static méthode

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.
Résultat static

tomorrow() public static méthode

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.
Résultat static

yesterday() public static méthode

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.
Résultat static

Property Details

$_lastErrors protected_oe static_oe property

Holds the last error generated by createFromFormat
protected static array $_lastErrors
Résultat array