SagentsLiveDebugger.Timezone (Sagents LiveDebugger v0.6.1)

Copy Markdown

Helpers for validating IANA timezone strings received from the browser.

The debugger passes the browser's detected timezone (from Intl.DateTimeFormat().resolvedOptions().timeZone) through the LiveSocket connect_params as "time_zone". This module ensures that only valid zones known to the host application's configured Calendar time zone database make it into socket state, so downstream DateTime.shift_zone/2 calls cannot crash when rendering event timestamps.

Summary

Functions

Validates a timezone string against the configured Calendar time zone database.

Validates a timezone and falls back to "UTC" on any failure.

Functions

validate(timezone)

@spec validate(any()) :: {:ok, String.t()} | {:error, :invalid_timezone}

Validates a timezone string against the configured Calendar time zone database.

Returns {:ok, timezone} for recognized zones, {:error, :invalid_timezone} otherwise (including for nil or non-binary input).

validate_or_utc(timezone)

@spec validate_or_utc(any()) :: String.t()

Validates a timezone and falls back to "UTC" on any failure.