TimeZoneNamedType-level representation of TimeZoneNamed.
export interface TimeZoneNamed extends interface declare<T, Iso = T>Creates a schema for a non-parametric opaque type using a type-guard
function. The schema accepts any unknown value and succeeds when is returns
true, failing with an InvalidType issue otherwise.
When to use
Use when you are defining a schema for an opaque type with no type parameters
and validation can be expressed as a type guard.
Example (Defining a schema for a custom UserId branded type)
import { Schema } from "effect"
type UserId = string & { readonly _tag: "UserId" }
const isUserId = (u: unknown): u is UserId =>
typeof u === "string" && u.startsWith("user_")
const UserId = Schema.declare<UserId>(isUserId, {
title: "UserId",
description: "A user identifier starting with 'user_'"
})
Type-level representation returned by
declare
.
declare<import DateTimeDateTime.TimeZone.interface TimeZone.NamedNamed IANA time zone.
Details
The id field contains the resolved time zone identifier, such as
"Europe/London" or "America/New_York".
Named> {
readonly "Rebuild": TimeZoneNamed
}
const const TimeZoneNamedString: Stringconst TimeZoneNamedString: {
Rebuild: Rebuild;
Iso: Iso;
ast: Ast;
Type: T;
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
annotate: (annotations: Annotations.Bottom<string, readonly []>) => String;
annotateKey: (annotations: Annotations.Key<string>) => String;
check: (checks_0: SchemaAST.Check<string>, ...checks: Array<SchemaAST.Check<string>>) => String;
rebuild: (ast: SchemaAST.String) => String;
make: (input: string, options?: MakeOptions) => string;
makeOption: (input: string, options?: MakeOptions) => Option_.Option<string>;
makeEffect: (input: string, options?: MakeOptions) => Effect.Effect<string, SchemaError, never>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
TimeZoneNamedString = const String: Stringconst String: {
Rebuild: Rebuild;
Iso: Iso;
ast: Ast;
Type: T;
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
annotate: (annotations: Annotations.Bottom<string, readonly []>) => String;
annotateKey: (annotations: Annotations.Key<string>) => String;
check: (checks_0: SchemaAST.Check<string>, ...checks: Array<SchemaAST.Check<string>>) => String;
rebuild: (ast: SchemaAST.String) => String;
make: (input: string, options?: MakeOptions) => string;
makeOption: (input: string, options?: MakeOptions) => Option_.Option<string>;
makeEffect: (input: string, options?: MakeOptions) => Effect.Effect<string, SchemaError, never>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
Type-level representation of
String
.
Schema for string values. Validates that the input is typeof "string".
String.Bottom<string, string, never, never, String, String, string, string, readonly [], string, "readonly", "required", "no-default", "readonly", "required">.annotate(annotations: Annotations.Bottom<string, readonly []>): Stringannotate({ Annotations.Augment.expected?: string | undefinedHuman-readable description of what a value is expected to satisfy.
Details
For filter and refinement failures, the default formatter uses
message first, then expected, and finally falls back to <filter>.
Use this to name a failed filter in the default message:
Expected <expected>, got <actual>.
expected: "an IANA time zone identifier" })
/**
* Schema for `DateTime.TimeZone.Named` values.
*
* **Details**
*
* Default JSON serializer:
*
* - encodes `DateTime.TimeZone.Named` as a string (IANA time zone identifier)
*
* @category DateTime
* @since 3.10.0
*/
export const const TimeZoneNamed: TimeZoneNamedconst TimeZoneNamed: {
Rebuild: TimeZoneNamed;
Iso: Iso;
ast: Ast;
Type: T;
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
annotate: (annotations: Annotations.Bottom<DateTime.TimeZone.Named, readonly []>) => TimeZoneNamed;
annotateKey: (annotations: Annotations.Key<DateTime.TimeZone.Named>) => TimeZoneNamed;
check: (checks_0: SchemaAST.Check<DateTime.TimeZone.Named>, ...checks: Array<SchemaAST.Check<DateTime.TimeZone.Named>>) => TimeZoneNamed;
rebuild: (ast: SchemaAST.Declaration) => TimeZoneNamed;
make: (input: DateTime.TimeZone.Named, options?: MakeOptions) => DateTime.TimeZone.Named;
makeOption: (input: DateTime.TimeZone.Named, options?: MakeOptions) => Option_.Option<DateTime.TimeZone.Named>;
makeEffect: (input: DateTime.TimeZone.Named, options?: MakeOptions) => Effect.Effect<DateTime.TimeZone.Named, SchemaError, never>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
Type-level representation of
TimeZoneNamed
.
Schema for DateTime.TimeZone.Named values.
Details
Default JSON serializer:
- encodes
DateTime.TimeZone.Named as a string (IANA time zone identifier)
TimeZoneNamed: TimeZoneNamed = function declare<T, Iso = T>(
is: (u: unknown) => u is T,
annotations?:
| Annotations.Declaration<T>
| undefined
): declare<T, Iso>
Creates a schema for a non-parametric opaque type using a type-guard
function. The schema accepts any unknown value and succeeds when is returns
true, failing with an InvalidType issue otherwise.
When to use
Use when you are defining a schema for an opaque type with no type parameters
and validation can be expressed as a type guard.
Example (Defining a schema for a custom UserId branded type)
import { Schema } from "effect"
type UserId = string & { readonly _tag: "UserId" }
const isUserId = (u: unknown): u is UserId =>
typeof u === "string" && u.startsWith("user_")
const UserId = Schema.declare<UserId>(isUserId, {
title: "UserId",
description: "A user identifier starting with 'user_'"
})
declare(
import DateTimeDateTime.const isTimeZoneNamed: (
u: unknown
) => u is DateTime.TimeZone.Named
Checks whether a value is a named TimeZone (IANA time zone).
When to use
Use to narrow an unknown value to the TimeZone.Named variant before
reading named-zone fields such as id.
isTimeZoneNamed,
{
Annotations.Declaration<TimeZone.Named, readonly []>.typeConstructor?: {
readonly [key: string]: unknown;
readonly _tag: string;
} | undefined
typeConstructor: {
_tag: string_tag: "effect/DateTime.TimeZone.Named"
},
Annotations.Declaration<TimeZone.Named, readonly []>.generation?: {
readonly runtime: string;
readonly Type: string;
readonly Encoded?: string | undefined;
readonly importDeclaration?: string | undefined;
} | undefined
generation: {
runtime: stringruntime: `Schema.TimeZoneNamed`,
type Type: stringType: `DateTime.TimeZone.Named`,
importDeclaration?: string | undefinedimportDeclaration: `import * as DateTime from "effect/DateTime"`
},
Annotations.Augment.expected?: string | undefinedHuman-readable description of what a value is expected to satisfy.
Details
For filter and refinement failures, the default formatter uses
message first, then expected, and finally falls back to <filter>.
Use this to name a failed filter in the default message:
Expected <expected>, got <actual>.
expected: "DateTime.TimeZone.Named",
Annotations.Declaration<TimeZone.Named, readonly []>.toCodecJson?: ((typeParameters: readonly []) => SchemaAST.Link) | undefinedtoCodecJson: () =>
function link<T>(): <
To extends Constraint
>(
encodeTo: To,
transformation: {
readonly decode: SchemaGetter.Getter<
T,
NoInfer<To["Type"]>
>
readonly encode: SchemaGetter.Getter<
NoInfer<To["Type"]>,
T
>
}
) => SchemaAST.Link
Constructs an SchemaAST.Link that describes how a value of type T encodes to and decodes from a To schema.
Used when building low-level AST transformations that bridge two schema types.
link<import DateTimeDateTime.TimeZone.interface TimeZone.NamedNamed IANA time zone.
Details
The id field contains the resolved time zone identifier, such as
"Europe/London" or "America/New_York".
Named>()(
const TimeZoneNamedString: Stringconst TimeZoneNamedString: {
Rebuild: Rebuild;
Iso: Iso;
ast: Ast;
Type: T;
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
annotate: (annotations: Annotations.Bottom<string, readonly []>) => String;
annotateKey: (annotations: Annotations.Key<string>) => String;
check: (checks_0: SchemaAST.Check<string>, ...checks: Array<SchemaAST.Check<string>>) => String;
rebuild: (ast: SchemaAST.String) => String;
make: (input: string, options?: MakeOptions) => string;
makeOption: (input: string, options?: MakeOptions) => Option_.Option<string>;
makeEffect: (input: string, options?: MakeOptions) => Effect.Effect<string, SchemaError, never>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
TimeZoneNamedString,
import SchemaTransformationSchemaTransformation.const timeZoneNamedFromString: Transformation<
DateTime.TimeZone.Named,
string
>
const timeZoneNamedFromString: {
_tag: 'Transformation';
decode: SchemaGetter.Getter<T, E, RD>;
encode: SchemaGetter.Getter<E, T, RE>;
flip: () => SchemaTransformation.Transformation<string, DateTime.TimeZone.Named, never, never>;
compose: (other: SchemaTransformation.Transformation<T2, DateTime.TimeZone.Named, RD2, RE2>) => SchemaTransformation.Transformation<T2, string, RD2, RE2>;
}
Decodes an IANA time-zone identifier string into a
DateTime.TimeZone.Named and encodes a named time zone back to its id.
When to use
Use when you need a schema transformation to accept only IANA time-zone
identifier strings and produce DateTime.TimeZone.Named values.
Details
Decode fails with InvalidValue when the string is not a valid IANA time-zone
identifier.
timeZoneNamedFromString
),
Annotations.Declaration<TimeZone.Named, readonly []>.toArbitrary?: Annotations.ToArbitrary.Declaration<DateTime.TimeZone.Named, readonly []> | undefinedtoArbitrary: () => (fc: typeof FastCheckfc) =>
fc: typeof FastCheckfc.constantFrom(
...["UTC", "Europe/London", "America/New_York", "Asia/Tokyo", "Australia/Sydney"].Array<string>.map<DateTime.TimeZone.Named>(callbackfn: (value: string, index: number, array: string[]) => DateTime.TimeZone.Named, thisArg?: any): DateTime.TimeZone.Named[]Calls a defined callback function on each element of an array, and returns an array that contains the results.
map(
import DateTimeDateTime.const zoneMakeNamedUnsafe: (
zoneId: string
) => DateTime.TimeZone.Named
Attempts to create a named time zone from an IANA time zone identifier.
When to use
Use when the IANA zone id is trusted and invalid zones should throw instead
of returning Option.none or failing in Effect.
Details
If the time zone is invalid, an IllegalArgumentError will be thrown.
Example (Creating named time zones unsafely)
import { DateTime } from "effect"
const londonZone = DateTime.zoneMakeNamedUnsafe("Europe/London")
console.log(DateTime.zoneToString(londonZone)) // "Europe/London"
const tokyoZone = DateTime.zoneMakeNamedUnsafe("Asia/Tokyo")
console.log(DateTime.zoneToString(tokyoZone)) // "Asia/Tokyo"
// This would throw an IllegalArgumentError:
// DateTime.zoneMakeNamedUnsafe("Invalid/Zone")
zoneMakeNamedUnsafe
)
),
Annotations.Declaration<TimeZone.Named, readonly []>.toFormatter?: Annotations.ToFormatter.Declaration<DateTime.TimeZone.Named, readonly []> | undefinedtoFormatter: () => (tz: DateTime.TimeZone.Named(parameter) tz: {
_tag: "Named";
id: string;
format: Intl.DateTimeFormat;
toString: () => string;
toJSON: () => unknown;
}
tz) => import DateTimeDateTime.const zoneToString: (
self: TimeZone
) => string
Formats a TimeZone as a string.
Example (Formatting time zones)
import { DateTime } from "effect"
// Outputs "+03:00"
DateTime.zoneToString(DateTime.zoneMakeOffset(3 * 60 * 60 * 1000))
// Outputs "Europe/London"
DateTime.zoneToString(DateTime.zoneMakeNamedUnsafe("Europe/London"))
zoneToString(tz: DateTime.TimeZone.Named(parameter) tz: {
_tag: "Named";
id: string;
format: Intl.DateTimeFormat;
toString: () => string;
toJSON: () => unknown;
}
tz),
Annotations.Declaration<TimeZone.Named, readonly []>.toEquivalence?: Annotations.ToEquivalence.Declaration<DateTime.TimeZone.Named, readonly []> | undefinedtoEquivalence: () => (a: DateTime.TimeZone.Named(parameter) a: {
_tag: "Named";
id: string;
format: Intl.DateTimeFormat;
toString: () => string;
toJSON: () => unknown;
}
a, b: DateTime.TimeZone.Named(parameter) b: {
_tag: "Named";
id: string;
format: Intl.DateTimeFormat;
toString: () => string;
toJSON: () => unknown;
}
b) => a: DateTime.TimeZone.Named(parameter) a: {
_tag: "Named";
id: string;
format: Intl.DateTimeFormat;
toString: () => string;
toJSON: () => unknown;
}
a.TimeZone.Named.id: stringid === b: DateTime.TimeZone.Named(parameter) b: {
_tag: "Named";
id: string;
format: Intl.DateTimeFormat;
toString: () => string;
toJSON: () => unknown;
}
b.TimeZone.Named.id: stringid
}
)