Class org.as2lib.data.type.Time

Description

Time is a holder for a time difference.

Time splits a time difference (distance between two dates) into days, hours, minutes, seconds and milliseconds to offers methods to access the time difference value.

There are two ways to access the Time instance:

The first way is by in*()( inHours(), inMinutes(),...). Those methods are coversions to the different time units. You can recieve the complete value in a different unit. Example: var time:Time = new Time(1.5, "d"); trace(time.inDays()); // 1.5 trace(time.inHours()); // 36 trace(time.inMinutes()); // 2160

The second way is by get*()( getHours(), getMinutes(),...). Those methods contain only the part of each unit that is contained within the value. Example: var time:Time = new Time(1.5, "d"); trace(time.getDays()); // 1.5 trace(time.getHours()); // 12 trace(time.getMinutes(); // 0

Its possible to pass-in a number in to round the value to the next lower case: Example: var time:Time = new Time(1.5, "d"); trace(time.getDays(0)); // 1

Method Index

new Time()
getDays(), getHours(), getMilliSeconds(), getMinutes(), getSeconds(), inDays(), inHours(), inMilliSeconds(), inMinutes(), inSeconds(), minus(), plus(), setValue(), toString(), valueOf()

Constructor Detail

Time

public function Time(timeDifference:Number, format:String)

Constructs a new Time instance.

Uses "ms" if no format or a wrong format was passed-in.

Uses Number.MAX_VALUE if Infinity was passed-in.

Parameters

format(optional) "d"/"h"/"m"/"s"/"ms" for the unit of the amout, default case is "ms"

Method Detail

setValue

public function setValue(timeDifference:Number, format:String):Time

Sets the time of the instance.

Uses "ms" if no format or a wrong format was passed-in.

Uses Number.MAX_VALUE if Infinity was passed-in.

Parameters

format(optional) "d"/"h"/"m"/"s"/"ms" for the unit of the amout. Default value is ms.

plus

public function plus(timeDifference:Time):Time

Adds the passed-in timedistance to the current time.

Parameters

timeDifferencetime difference to be added to the current time

Return

new instance with the resulting amount of time

minus

public function minus(timeDifference:Time):Time

Adds the passed-in timeDifference from the current time.

Parameters

timeDifferencetime difference to be removed from the current time

Return

new instance with the resulting amount of time

getMilliSeconds

public function getMilliSeconds(round:Number):Number

Getter for the amount of milliseconds are contained within the time.

It will not round the result if you pass-in nothing.

Parameters

round(optional) the number of decimal spaces

Return

time difference in milliseconds

inMilliSeconds

public function inMilliSeconds(Void):Number

Getter for the time distance in milliseconds.

Return

time difference in milliseconds

getSeconds

public function getSeconds(round:Number):Number

Getter for the amount of seconds are contained within the time.

It will not round the result if you pass-in nothing.

Parameters

round(optional) the number of decimal spaces

Return

time difference in seconds

inSeconds

public function inSeconds(Void):Number

Getter for the time distance in seconds.

Return

time difference in seconds

getMinutes

public function getMinutes(round:Number):Number

Getter for the amount of minutes are contained within the time.

It will not round the result if you pass-in nothing.

Parameters

round(optional) the number of decimal spaces

Return

time difference in minutes

inMinutes

public function inMinutes(Void):Number

Getter for the time distance in minutes.

Return

time difference in minutes

getHours

public function getHours(round:Number):Number

Getter for the amount of hours are contained within the time.

It will not round the result if you pass-in nothing.

Parameters

round(optional) the number of decimal spaces

Return

time difference in hours

inHours

public function inHours(Void):Number

Getter for the time distance in hours.

Return

time difference in hours

getDays

public function getDays(round:Number):Number

Getter for the amount of days are contained within the time.

It will not round the result if you pass-in nothing.

Parameters

round(optional) the number of decimal spaces

Return

time difference in days

inDays

public function inDays(Void):Number

Getter for the time distance in days.

Return

time difference in days

toString

public function toString():String

Generates String representation of the time.

Return

time difference as string

Specified By

toString() in org.as2lib.core.BasicInterface

Overrides

toString() in org.as2lib.core.BasicClass

valueOf

public function valueOf():Number

Returns the value of the time distance (in ms).

Return

value in ms