Reference · Dates

date.valid_zone

signature
date.valid_zone(any) -> bool

What it does

Whether a value is a time zone: a name of the IANA database, a zone or a link, in any case ("Europe/Paris", "US/Pacific", "EST"), an offset as date.parse reads one ("+05:45", "+0530", "+05", up to +23:59), or "UTC". The server and the browser take the same zones and refuse the same names. A zone is among the commonest values a program takes from a person, and one that does not exist stops date.to_zone, so ask first, or guard it with ??.

Examples

print(date.valid_zone("Europe/Paris"))print(date.valid_zone("+05:45"))print(date.valid_zone("Mars/Base"))print(date.to_zone("2026-10-27T14:30:00Z", "Mars/Base") ?? "no such zone")
output
truetruefalseno such zone

Edge cases

print(["europe/paris", "US/Pacific", "EST", "+0530", "+05", "+23:59"] | map(date.valid_zone))print(["PST", "posixrules", "Factory", "right/UTC", "US/Pacific-New", "+5", "+24:00"] | map(date.valid_zone))print(date.from_ms(1793543400000, "+0530"), date.to_zone("2026-10-27T14:30:00Z", "europe/paris"))
output
[true, true, true, true, true, true][false, false, false, false, false, false, false]2026-11-01T20:00:00+05:30 2026-10-27T15:30:00+01:00
Thread
1Useful? Like it, or add to its thread below.

Thread 0 posts

On date.valid_zone(): questions, tips, corrections, and code that uses it.

No posts yet. The first one opens the thread.

    Edit this page on GitHub · every example's output was made by running it (tools/refcheck.mjs) · questions on Discord or r/quillo