Type guard to check if a value is a valid Luxon Zone instance.
Note that this includes the UnsetZone sentinel value.
Checks both instanceof Zone and constructor name to handle cross-module Zone instances that may not pass instanceof checks.
instanceof Zone
Value to check
true if the value is a Zone instance (type guard)
import { Info } from "luxon"const zone = Info.normalizeZone("UTC+8")if (isZone(zone)) { // TypeScript knows zone is Zone (not unknown) console.log(zone.offset(Date.now()))}isZone(Info.normalizeZone("UTC")) // trueisZone("UTC") // falseisZone(480) // falseisZone(null) // false Copy
import { Info } from "luxon"const zone = Info.normalizeZone("UTC+8")if (isZone(zone)) { // TypeScript knows zone is Zone (not unknown) console.log(zone.offset(Date.now()))}isZone(Info.normalizeZone("UTC")) // trueisZone("UTC") // falseisZone(480) // falseisZone(null) // false
Type guard to check if a value is a valid Luxon Zone instance.
Note that this includes the UnsetZone sentinel value.
Checks both
instanceof Zoneand constructor name to handle cross-module Zone instances that may not pass instanceof checks.