PHP 클래스 Cake\Chronos\ChronosInterval

The implementation provides helpers to handle weeks but only days are saved. Weeks are calculated based on the total days of the current instance.
상속: extends DateInterva\DateInterval
파일 보기 프로젝트 열기: cakephp/chronos 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$isHHVM boolean Whether or not this object was created in HHVM

공개 메소드들

메소드 설명
__call ( string $name, array $args ) : static Allow fluent calls on the setters.
__callStatic ( string $name, array $args ) : static Provide static helpers to create instances. Allows:
__construct ( integer | null $years = 1, integer | null $months = null, integer | null $weeks = null, integer | null $days = null, integer | null $hours = null, integer | null $minutes = null, integer | null $seconds = null ) Create a new ChronosInterval instance.
__get ( string $name ) : integer Get a part of the ChronosInterval object
__set ( string $name, integer $val ) : void Set a part of the ChronosInterval object
__toString ( ) : string Returns the ISO 8601 interval string.
add ( DateInterval $interval ) : static Add the passed interval to the current instance
create ( integer | null $years = 1, integer | null $months = null, integer | null $weeks = null, integer | null $days = null, integer | null $hours = null, integer | null $minutes = null, integer | null $seconds = null ) : static Create a new ChronosInterval instance from specific values.
instance ( DateInterval $di ) : static Create a ChronosInterval instance from a DateInterval one. Can not instance DateInterval objects created from DateTime::diff() as you can't externally set the $days field.
weeksAndDays ( integer $weeks, integer $days ) : static Allow setting of weeks and days to be cumulative.

보호된 메소드들

메소드 설명
wasCreatedFromDiff ( DateInterval $interval ) : boolean Determine if the interval was created via DateTime:diff() or not.

메소드 상세

__call() 공개 메소드

.. ChronosInterval::years(3)->months(5)->day(). Note: This is done using the magic method to allow static and instance methods to have the same names.
public __call ( string $name, array $args ) : static
$name string The property name to augment. Accepts plural forms in addition to singular ones.
$args array The value to set.
리턴 static

__callStatic() 공개 정적인 메소드

ChronosInterval::years(3) or ChronosInterval::month(1); Note: This is done using the magic method to allow static and instance methods to have the same names.
public static __callStatic ( string $name, array $args ) : static
$name string The property to configure. Accepts singular and plural forms.
$args array Contains the value to use.
리턴 static

__construct() 공개 메소드

Create a new ChronosInterval instance.
public __construct ( integer | null $years = 1, integer | null $months = null, integer | null $weeks = null, integer | null $days = null, integer | null $hours = null, integer | null $minutes = null, integer | null $seconds = null )
$years integer | null The year to use.
$months integer | null The month to use.
$weeks integer | null The week to use.
$days integer | null The day to use.
$hours integer | null The hours to use.
$minutes integer | null The minutes to use.
$seconds integer | null The seconds to use.

__get() 공개 메소드

Get a part of the ChronosInterval object
public __get ( string $name ) : integer
$name string The property to read.
리턴 integer

__set() 공개 메소드

Set a part of the ChronosInterval object
public __set ( string $name, integer $val ) : void
$name string The property to augment.
$val integer The value to change.
리턴 void

__toString() 공개 메소드

Returns the ISO 8601 interval string.
public __toString ( ) : string
리턴 string Interval as string representation

add() 공개 메소드

Add the passed interval to the current instance
public add ( DateInterval $interval ) : static
$interval DateInterval The interval to add.
리턴 static

create() 공개 정적인 메소드

This is an alias for the constructor that allows better fluent syntax as it allows you to do ChronosInterval::create(1)->fn() rather than (new ChronosInterval(1))->fn().
public static create ( integer | null $years = 1, integer | null $months = null, integer | null $weeks = null, integer | null $days = null, integer | null $hours = null, integer | null $minutes = null, integer | null $seconds = null ) : static
$years integer | null The year to use.
$months integer | null The month to use.
$weeks integer | null The week to use.
$days integer | null The day to use.
$hours integer | null The hours to use.
$minutes integer | null The minutes to use.
$seconds integer | null The seconds to use.
리턴 static

instance() 공개 정적인 메소드

Create a ChronosInterval instance from a DateInterval one. Can not instance DateInterval objects created from DateTime::diff() as you can't externally set the $days field.
public static instance ( DateInterval $di ) : static
$di DateInterval The DateInterval instance to copy.
리턴 static

wasCreatedFromDiff() 보호된 정적인 메소드

Determine if the interval was created via DateTime:diff() or not.
protected static wasCreatedFromDiff ( DateInterval $interval ) : boolean
$interval DateInterval The interval to check.
리턴 boolean

weeksAndDays() 공개 메소드

Allow setting of weeks and days to be cumulative.
public weeksAndDays ( integer $weeks, integer $days ) : static
$weeks integer Number of weeks to set
$days integer Number of days to set
리턴 static

프로퍼티 상세

$isHHVM 보호되어 있는 프로퍼티

Whether or not this object was created in HHVM
protected bool $isHHVM
리턴 boolean