Time
Added in version v1.5.0.
local Time = require("Starlit/utils/Time")
The Time module contains utilities for working with real and game time values. For scheduling functions, see TaskManager.
Enums
Functions
-
Time.durationToRealTime(time:
number
)number
Converts a game time duration to real time.
- Parameters:
time (
number
) – Game time duration. The unit doesn’t matter, but other functions in this module expect hours.- Returns:
number – Real time equivalent of <i>hours</i> in the same unit as given.
-
Time.durationToGameTime(time:
number
)number
Converts a real time duration to game time.
- Parameters:
time (
number
) – Real time duration. The unit doesn’t matter, but other functions in this module expect hours.- Returns:
number – Game time equivalent of <i>hours</i> in the same unit as given.
-
Time.formatDuration(time:
number
, minUnit:starlit.Time.UnitName
|nil
, maxUnit:starlit.Time.UnitName
|nil
)string
Formats a string describing a time duration. The result is suitable for display to the user.
- Parameters:
time (
number
) – Duration in hours.minUnit (
starlit.Time.UnitName
|nil
) – Smallest unit to render the time in. If nil, a reasonable value will be calculated.maxUnit (
starlit.Time.UnitName
|nil
) – Largest unit to render the time in. If nil, a reasonable value will be calculated.
- Returns:
string – String description of the duration <i>time</i>.