Class Duration

Description

I represent a duration of time. I have been tested to support durations of up to 4 billion (4,000,000,000) years with second precision and up to 50 billion (50,000,000) years with hour precision. Durations beyond 50 billion years have not been tested.

To create new Duration instances, use one of the static instance-creation methods, NOT 'new Duration':

    Located in /harmoni/core/Primitives/Chronology/Duration.class.php (line 49)

    SObject
       |
       --Magnitude
          |
          --Duration
    Method Summary
    object Duration Duration (integer $seconds)
    integer asSeconds ()
    integer days ()
    object Duration dividedBy (mixed $operand, object Duration $aDuration)
    object Duration fromString (string $aString)
    integer hours ()
    boolean isEqualTo (object Duration $aDuration)
    boolean isLessThan (object Duration $aDuration)
    boolean isNegative ()
    boolean isPositive ()
    integer minutes ()
    object Duration multipliedBy (mixed $operand, object Duration $aDuration)
    string printableString ()
    integer seconds ()
    array ticks ()
    object Duration withDays (integer $days)
    object Duration withDaysHoursMinutesSeconds (integer $days, integer $hours, integer $minutes, integer $seconds)
    object Duration withHours (integer $hours)
    object Duration withMinutes (integer $minutes)
    object Duration withMonth (string $anIntOrStrMonth)
    object Duration withSeconds (integer $seconds)
    object Duration withWeeks (float $aNumber)
    Methods
    Constructor Duration (line 213)

    Initialize this Duration.

    • since: 5/3/05
    • access: private
    object Duration Duration (integer $seconds)
    • integer $seconds: seconds
    abs (line 417)

    Return the absolute value of this duration.

    • since: 5/3/05
    • access: public
    asDuration (line 555)

    Answer a Duration that represents this object.

    • since: 5/4/05
    • access: public
    object Duration asDuration ()
    asSeconds (line 544)

    Answer the duration in seconds.

    • since: 5/3/05
    • access: public
    integer asSeconds ()
    days (line 243)

    Answer the number of days the receiver represents.

    • since: 5/3/05
    • access: public
    integer days ()
    dividedBy (line 430)

    Divide a Duration. Operand is a Duration or a Number

    • return: The result
    • since: 5/12/05
    • access: public
    object Duration dividedBy (mixed $operand, object Duration $aDuration)
    fromString (line 66)

    Formatted as per ANSI 5.8.2.16: [-]D:HH:MM:SS[.S]

    • static:
    • since: 5/13/05
    • access: public
    object Duration fromString (string $aString)
    • string $aString
    hours (line 258)

    Answer the number of hours the receiver represents.

    • since: 5/3/05
    • access: public
    integer hours ()
    isEqualTo (line 390)

    Test if this Duration is equal to aDuration.

    • since: 5/3/05
    • access: public
    boolean isEqualTo (object Duration $aDuration)

    Redefinition of:
    Magnitude::isEqualTo()
    Test if this is equal to aMagnitude.
    isLessThan (line 402)

    Test if this Duration is less than aDuration.

    • since: 5/3/05
    • access: public
    boolean isLessThan (object Duration $aDuration)

    Redefinition of:
    Magnitude::isLessThan()
    Test if this is less than aMagnitude.
    isNegative (line 367)

    Return true if this Duration is negative.

    • since: 5/3/05
    • access: public
    boolean isNegative ()
    isPositive (line 378)

    Return true if this Duration is positive.

    • since: 5/3/05
    • access: public
    boolean isPositive ()
    minus (line 449)

    Subtract a Duration.

    • return: The result
    • since: 5/3/05
    • access: public
    object Duration minus (object Duration $aDuration)
    minutes (line 287)

    Answer the number of minutes the receiver represents.

    • since: 5/3/05
    • access: public
    integer minutes ()
    multipliedBy (line 462)

    Multiply a Duration. Operand is a Duration or a Number

    • return: The result
    • since: 5/12/05
    • access: public
    object Duration multipliedBy (mixed $operand, object Duration $aDuration)
    negated (line 480)

    Return the negative of this duration

    • since: 5/10/05
    • access: public
    object Duration negated ()
    plus (line 493)

    Add a Duration.

    • return: The result.
    • since: 5/3/05
    • access: public
    object Duration plus (object Duration $aDuration)
    printableString (line 316)

    Format as per ANSI 5.8.2.16: [-]D:HH:MM:SS[.S]

    • since: 5/3/05
    • access: public
    string printableString ()

    Redefinition of:
    SObject::printableString()
    Answer a String whose characters are a description of the receiver.
    roundTo (line 506)

    Round to a Duration.

    • return: The result.
    • since: 5/3/05
    • access: public
    object Duration roundTo (object Duration $aDuration)
    seconds (line 337)

    Answer the number of seconds the receiver represents.

    • since: 5/3/05
    • access: public
    integer seconds ()
    ticks (line 224)

    Answer an array {days. seconds. nanoSeconds}. Used by DateAndTime and Time

    • since: 5/2/05
    • access: private
    array ticks ()
    truncateTo (line 525)

    Truncate.

    e.g. if the receiver is 5 minutes, 37 seconds, and aDuration is 2 minutes, answer 4 minutes.

    • since: 5/13/05
    • access: public
    object Duration truncateTo (object Duration $aDuration)
    withDays (line 89)

    Create a new instance of days...

    • since: 5/3/05
    • static:
    • access: public
    object Duration withDays (integer $days)
    • integer $days
    withDaysHoursMinutesSeconds (line 106)

    Create a new instance with.

    • since: 5/3/05
    • static:
    • access: public
    object Duration withDaysHoursMinutesSeconds (integer $days, integer $hours, integer $minutes, integer $seconds)
    • integer $days
    • integer $hours
    • integer $minutes
    • integer $seconds
    withHours (line 125)

    Create a new Duration of hours...

    • since: 5/3/05
    • static:
    • access: public
    object Duration withHours (integer $hours)
    • integer $hours
    withMinutes (line 139)

    Create a new instance of minutes...

    • since: 5/3/05
    • static:
    • access: public
    object Duration withMinutes (integer $minutes)
    • integer $minutes
    withMonth (line 153)

    Create a new instance. aMonth is an Integer or a String

    • static:
    • since: 5/13/05
    • access: public
    object Duration withMonth (string $anIntOrStrMonth)
    • string $anIntOrStrMonth
    withSeconds (line 169)

    Create a new instance of seconds...

    • since: 5/3/05
    • static:
    • access: public
    object Duration withSeconds (integer $seconds)
    • integer $seconds
    withWeeks (line 182)

    Create a new instance of a number of weeks

    • since: 5/13/05
    • access: public
    object Duration withWeeks (float $aNumber)
    • float $aNumber
    zero (line 195)

    Create a new Duration of zero length

    • static:
    • since: 5/5/05
    • access: public
    object Duration zero ()

    Inherited Methods

    Inherited From Magnitude

    Magnitude::isBetween()
    Magnitude::isEqualTo()
    Magnitude::isGreaterThan()
    Magnitude::isGreaterThanOrEqualTo()
    Magnitude::isLessThan()
    Magnitude::isLessThanOrEqualTo()
    Magnitude::max()
    Magnitude::min()

    Inherited From SObject

    SObject::asA()
    SObject::asString()
    SObject::copy()
    SObject::copySameFrom()
    SObject::copyTwoLevel()
    SObject::deepCopy()
    SObject::isEqual()
    SObject::isEqualTo()
    SObject::isNotEqualTo()
    SObject::isNotReferenceTo()
    SObject::isReferenceTo()
    SObject::newFrom()
    SObject::postCopy()
    SObject::printableString()
    SObject::shallowCopy()
    SObject::_deepCopyArray()

    Documentation generated on Wed, 19 Sep 2007 10:22:51 -0400 by phpDocumentor 1.3.0RC3