Time - truemedian/Discordia GitHub Wiki

Represents a length of time and provides utilities for converting to and from different formats with millisecond precision.

Static Methods

fromWeeks
fromDays
fromHours
fromMinutes
fromSeconds
fromMilliseconds
fromTable

Methods

toString
toWeeks
toDays
toHours
toMinutes
toSeconds
toMilliseconds
toTable

Static Methods

.fromWeeks( t )

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

Name Type
t number

Returns: Time

.fromDays( t )

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

Name Type
t number

Returns: Time

.fromHours( t )

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

Name Type
t number

Returns: Time

.fromMinutes( t )

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

Name Type
t number

Returns: Time

.fromSeconds( t )

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

Name Type
t number

Returns: Time

.fromMilliseconds( t )

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

Name Type
t number

Returns: Time

.fromTable( t )

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

Name Type
t table

Returns: Time

Methods

:toString( )

Returns a string from the normalized time values that can be used to represent the time object in a string form.

Returns: string

:toWeeks( )

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

Returns: number

:toDays( )

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

Returns: number

:toHours( )

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

Returns: number

:toMinutes( )

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

Returns: number

:toSeconds( )

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

Returns: number

:toMilliseconds( )

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

Returns: number

:toTable( )

Returns a table of normalized time values that can be used to represent the time object in a more human-readable form.

Returns: number

⚠️ **GitHub.com Fallback** ⚠️