Skip to content

TimeZoneSchema

const TimeZoneSchema: transform<filter<typeof String$>, declare<TimeZone, TimeZone, readonly [], never>>;

Defined in: effect-utils.ts:27

Effect schema: validate an IANA id and brand it as TimeZone. Fails with the message "Invalid IANA time zone". The value is not canonicalized. It is a two-way transformation: the encoded side is a plain string, so Schema.encodeSync gives the string back.

import { Either, Schema } from "effect";
import { TimeZoneSchema } from "@xtandard/lib/effect";
const Settings = Schema.Struct({ timeZone: TimeZoneSchema });
Schema.decodeUnknownSync(Settings)({ timeZone: "Europe/Berlin" }); // { timeZone: "Europe/Berlin" }
Either.isLeft(Schema.decodeUnknownEither(TimeZoneSchema)("Mars/Olympus")); // true