Skip to content
SinisterRectus edited this page Oct 23, 2022 · 7 revisions

Represents a length of time and provides utilities for converting to and from different formats. Supported units are: weeks, days, hours, minutes, seconds, and milliseconds.

Constructor

Time(value)

Parameter Type Optional
value number

Static Methods

fromDays(t)

Parameter Type
t number

Constructs a new Time object from a value interpreted as days, where a day is equal to 24 hours.

This method only operates on data in memory.

Returns: Time


fromHours(t)

Parameter Type
t number

Constructs a new Time object from a value interpreted as hours, where an hour is equal to 60 minutes.

This method only operates on data in memory.

Returns: Time


fromMilliseconds(t)

Parameter Type
t number

Constructs a new Time object from a value interpreted as milliseconds, the base unit represented.

This method only operates on data in memory.

Returns: Time


fromMinutes(t)

Parameter Type
t number

Constructs a new Time object from a value interpreted as minutes, where a minute is equal to 60 seconds.

This method only operates on data in memory.

Returns: Time


fromSeconds(t)

Parameter Type
t number

Constructs a new Time object from a value interpreted as seconds, where a second is equal to 1000 milliseconds.

This method only operates on data in memory.

Returns: Time


fromTable(t)

Parameter Type
t table

Constructs a new Time object from a table of time values where the keys are defined in the constructors above (eg: weeks, days, hours).

This method only operates on data in memory.

Returns: Time


fromWeeks(t)

Parameter Type
t number

Constructs a new Time object from a value interpreted as weeks, where a week is equal to 7 days.

This method only operates on data in memory.

Returns: Time


Methods

toDays()

Returns the total number of days that the time object represents.

This method only operates on data in memory.

Returns: number


toHours()

Returns the total number of hours that the time object represents.

This method only operates on data in memory.

Returns: number


toMilliseconds()

Returns the total number of milliseconds that the time object represents.

This method only operates on data in memory.

Returns: number


toMinutes()

Returns the total number of minutes that the time object represents.

This method only operates on data in memory.

Returns: number


toSeconds()

Returns the total number of seconds that the time object represents.

This method only operates on data in memory.

Returns: number


toString()

Returns a human-readable string built from the set of normalized time values that the object represents.

This method only operates on data in memory.

Returns: string


toTable()

Returns a table of normalized time values that represent the time object in a more accessible form.

This method only operates on data in memory.

Returns: number


toWeeks()

Returns the total number of weeks that the time object represents.

This method only operates on data in memory.

Returns: number


Clone this wiki locally