Access keys

Time

Kind of class: class
Inherits from: BasicClass
Version: 1.0
Author: Martin Heidegger
Classpath: org.as2lib.data.type.Time
File last modified: Thursday, 15 September 2005, 18:43:44
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

Constructor

Time

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:
time :
size of the time difference for the passed-in format
format:
(optional) "d"/"h"/"m"/"s"/"ms" for the unit of the amout,
default case is "ms"

Instance methods

getDays

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
Returns:
time difference in days

getHours

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
Returns:
time difference in hours

getMilliSeconds

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
Returns:
time difference in milliseconds

getMinutes

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
Returns:
time difference in minutes

getSeconds

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
Returns:
time difference in seconds

inDays

function inDays (
Void) : Number
Getter for the time distance in days.
Returns:
time difference in days

inHours

function inHours (
Void) : Number
Getter for the time distance in hours.
Returns:
time difference in hours

inMilliSeconds

function inMilliSeconds (
Void) : Number
Getter for the time distance in milliseconds.
Returns:
time difference in milliseconds

inMinutes

function inMinutes (
Void) : Number
Getter for the time distance in minutes.
Returns:
time difference in minutes

inSeconds

function inSeconds (
Void) : Number
Getter for the time distance in seconds.
Returns:
time difference in seconds

minus

function minus (
timeDifference:Time) : Time
Adds the passed-in timeDifference from the current time.
Parameters:
timeDifference:
time difference to be removed from the current time
Returns:
new instance with the resulting amount of time

plus

function plus (
timeDifference:Time) : Time
Adds the passed-in timedistance to the current time.
Parameters:
timeDifference:
time difference to be added to the current time
Returns:
new instance with the resulting amount of time

setValue

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:
time :
size of the time difference for the passed-in format
format:
(optional) "d"/"h"/"m"/"s"/"ms" for the unit of the amout.
Default value is ms.

toString

function toString (
) : String
Generates String representation of the time.
Returns:
time difference as string

valueOf

function valueOf (
) : Number
Returns the value of the time distance (in ms).
Returns:
value in ms