Skip to content

smelt.time

Tier: Host - Available in every runtime, including headless mode.

Visibility: Public - Stable Lua API intended for user config and plugins.

Wall-clock time parsing and formatting. Host-tier so plugins can render provider timestamps consistently in both TUI and headless contexts.

smelt.time.format

fun(timestamp: integer, format: string): string?

Format Unix seconds in the user's local time zone with a strftime-style format string.

smelt.time.format_utc

fun(timestamp: integer, format: string): string?

Format Unix seconds in UTC with a strftime-style format string.

smelt.time.now

fun(): integer

Return the current Unix timestamp in seconds. Backed by the host clock so tests can freeze time by swapping in a virtual clock.

smelt.time.now_ms

fun(): integer

Return the current Unix timestamp in milliseconds. Backed by the host clock so tests can freeze time by swapping in a virtual clock.

smelt.time.parse_iso8601

fun(timestamp: string): integer?

Parse an ISO-8601 / RFC3339 timestamp and return Unix seconds, not milliseconds, or nil when the input is invalid.