Overview

Namespaces

  • Apptus
    • ESales
      • Connector
        • Report
        • Time
    • Util
      • Cache
  • PHP

Classes

  • CalendarDate
  • Duration
  • IsoDate
  • IsoDateTime
  • Month
  • OrdinalDate
  • Time
  • TimeInterval
  • TimePoint
  • Unit
  • WeekDate
  • Weekday
  • Overview
  • Namespace
  • Class
  • Tree

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
Extended by Apptus\ESales\Connector\Time\Duration
Namespace: Apptus\ESales\Connector\Time
Located at Connector/Time/Duration.php
Methods summary
public static Apptus\ESales\Connector\Time\Duration
# parse( string $input )

Parses a duration.

Parses a duration.

Parameters

$input
in ISO 8601 format.

Returns

Apptus\ESales\Connector\Time\Duration
A new instance representing the same duration as the input.
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

$amount
$unit
of the string constants in Apptus\ESales\Connector\Time\Unit.

Returns

Apptus\ESales\Connector\Time\Duration

Throws

InvalidArgumentException
if the unit is invalid.
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

$d

Returns

Apptus\ESales\Connector\Time\Duration
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

$dt

Returns

DateTime
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

$dt

Returns

DateTime
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.
Methods inherited from DateInterval
__construct(), __set_state(), __wakeup(), createFromDateString(), format()
Apptus ESales Connector PHP API documentation generated by ApiGen