Time

The Time module contains utilities for working with real and game time values. For scheduling functions, see TaskManager.

Added in version v1.5.0.

Contains utilities for working with real and game time values. For scheduling functions, see TaskManager.

Require: require("Starlit/utils/Time")

Function

Starlit.utils.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:

_1 (number) – Game time equivalent of <i>hours</i> in the same unit as given.

Starlit.utils.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:

_1 (number) – Real time equivalent of <i>hours</i> in the same unit as given.

Starlit.utils.Time.formatDuration(
    time: number,
    minUnit?: starlit.Time.UnitName,
    maxUnit?: starlit.Time.UnitName
): 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) – Smallest unit to render the time in. If nil, a reasonable value will be calculated.

  • maxUnit? (starlit.Time.UnitName) – Largest unit to render the time in. If nil, a reasonable value will be calculated.

Returns:

_1 (string) – String description of the duration <i>time</i>.