Skip to main content
The Deno 2 Release Candidate is here
Learn more
Module

x/complaindate/mod.ts>safeTimezone

JavaScript date-time utilities that keeps timezones on the surface
Go to Latest
function safeTimezone
import { safeTimezone } from "https://deno.land/x/complaindate@v0.7.2/mod.ts";

Get a valid timezone name, adapted for the current user.

Falls back to the timezone of the local system if no valid timezone was found in the given string.

This is useful for sanitizing the current user's timezone preference into a guaranteed valid timezone before applying any operations taking that timezone as parameter. This avoids RangeError being thrown should the timezone be invalid.

Parameters

preferredTimezone: string

Returns

string