Class Duration
A duration on the form P[yY][mM][dD][T[hH][mM][sS]] or P[wW], that specifies
the length of a time interval.
This class describes a duration as defined by ISO 8601.
-
DateInterval
-
Apptus\ESales\Connector\Time\Duration
Methods summary
public static
Apptus\ESales\Connector\Time\Duration
|
#
parse( string $input )
Parses a duration.
Parameters
- $input
- in ISO 8601 format.
Returns
|
public static
Apptus\ESales\Connector\Time\Duration
|
#
create( integer $amount, string $unit )
Create a duration from an amount and a unit.
Create a duration from an amount and a unit.
Parameters
Returns
Throws
|
public
integer
|
#
amount( string $unit )
Returns the amount of a certain unit.
Returns the amount of a certain unit.
This is not a total amount, but instead the amount specified for the specified field.
Parameters
- $unit
- unit. Must be one of the constants in the Unit class.
Returns
integer
|
public
Apptus\ESales\Connector\Time\Duration
|
#
add( Apptus\ESales\Connector\Time\Duration $d )
Create a new Duration that is the sum of this duration and the argument duration.
Create a new Duration that is the sum of this duration and the argument duration.
Parameters
Returns
|
public
DateTime
|
#
forward( DateTime $dt )
Return a DateTime moved forward in time by the length of this duration.
Return a DateTime moved forward in time by the length of this duration.
Parameters
Returns
|
public
DateTime
|
#
back( DateTime $dt )
Return a DateTime moved back in time by the length of this duration.
Return a DateTime moved back in time by the length of this duration.
Parameters
Returns
|
public
string
|
#
precision( )
The finest unit with a specified amount for this duration.
The finest unit with a specified amount for this duration.
For instance, the duration PT1M has minute precision, while PT1M0S has second
precision (even if the number of seconds specified is zero).
Returns
string The smallest specified unit.
|
public
|
#
equals( $o )
True if the argument is a duration with the same or equivalent specification.
True if the argument is a duration with the same or equivalent specification.
Note that P1W equals P7D by definition, whereas e.g. P1M does not equal P30D
since months are not 30 days in general. Less obvious, P1D is not equal to
P24H in general.
Years are normalized to months, weeks to days and hours and minutes to seconds.
After normalization, both durations are compared component by component. Iff
all components match, this method returns true.
|
public
string
|
#
__toString( )
Returns a string with the ISO 8601 representation of this duration.
Returns a string with the ISO 8601 representation of this duration.
Returns
string The ISO 8601 representaion of this duration.
|