TimeZoneOffsetType-level representation of TimeZoneOffset.
export interface TimeZoneOffset 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.declareTimeZone.type DateTime.TimeZone.Offset = /*unresolved*/ anyOffset> {
readonly "Rebuild": TimeZoneOffset
}
/**
* Schema for `DateTime.TimeZone.Offset` values.
*
* **Details**
*
* Default JSON serializer:
*
* - encodes `DateTime.TimeZone.Offset` as a number (offset in milliseconds)
*
* @category DateTime
* @since 3.10.0
*/
export const const TimeZoneOffset: TimeZoneOffsetconst TimeZoneOffset: {
Rebuild: TimeZoneOffset;
Iso: Iso;
ast: Ast;
Type: T;
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
annotate: (annotations: Annotations.Bottom<DateTime.TimeZone.Offset, readonly []>) => TimeZoneOffset;
annotateKey: (annotations: Annotations.Key<DateTime.TimeZone.Offset>) => TimeZoneOffset;
check: (checks_0: SchemaAST.Check<DateTime.TimeZone.Offset>, ...checks: Array<SchemaAST.Check<DateTime.TimeZone.Offset>>) => TimeZoneOffset;
rebuild: (ast: SchemaAST.Declaration) => TimeZoneOffset;
make: (input: DateTime.TimeZone.Offset, options?: MakeOptions) => DateTime.TimeZone.Offset;
makeOption: (input: DateTime.TimeZone.Offset, options?: MakeOptions) => Option_.Option<DateTime.TimeZone.Offset>;
makeEffect: (input: DateTime.TimeZone.Offset, options?: MakeOptions) => Effect.Effect<DateTime.TimeZone.Offset, 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
TimeZoneOffset
.
Schema for DateTime.TimeZone.Offset values.
Details
Default JSON serializer:
- encodes
DateTime.TimeZone.Offset as a number (offset in milliseconds)
TimeZoneOffset: TimeZoneOffset = 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.isTimeZoneOffset,
{
Annotations.Declaration<DateTime.TimeZone.Offset, readonly []>.typeConstructor?: {
readonly [key: string]: unknown;
readonly _tag: string;
} | undefined
typeConstructor: {
_tag: string_tag: "effect/DateTime.TimeZone.Offset"
},
Annotations.Declaration<DateTime.TimeZone.Offset, readonly []>.generation?: {
readonly runtime: string;
readonly Type: string;
readonly Encoded?: string | undefined;
readonly importDeclaration?: string | undefined;
} | undefined
generation: {
runtime: stringruntime: `Schema.TimeZoneOffset`,
type Type: stringType: `DateTime.TimeZone.Offset`,
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.Offset",
Annotations.Declaration<DateTime.TimeZone.Offset, 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.declareTimeZone.type DateTime.TimeZone.Offset = /*unresolved*/ anyOffset>()(
const Number: Numberconst Number: {
Rebuild: Rebuild;
Iso: Iso;
ast: Ast;
Type: T;
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
annotate: (annotations: Annotations.Bottom<number, readonly []>) => Number;
annotateKey: (annotations: Annotations.Key<number>) => Number;
check: (checks_0: SchemaAST.Check<number>, ...checks: Array<SchemaAST.Check<number>>) => Number;
rebuild: (ast: SchemaAST.Number) => Number;
make: (input: number, options?: MakeOptions) => number;
makeOption: (input: number, options?: MakeOptions) => Option_.Option<number>;
makeEffect: (input: number, options?: MakeOptions) => Effect.Effect<number, 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
Number
.
Schema for number values, including NaN, Infinity, and -Infinity.
Details
Default JSON serializer:
- Finite numbers are serialized as numbers.
- Non-finite values are serialized as strings (
"NaN", "Infinity", "-Infinity").
Number,
import SchemaTransformationSchemaTransformation.const timeZoneOffsetFromNumber: Transformation<
DateTime.TimeZone.Offset,
number
>
const timeZoneOffsetFromNumber: {
_tag: 'Transformation';
decode: SchemaGetter.Getter<T, E, RD>;
encode: SchemaGetter.Getter<E, T, RE>;
flip: () => SchemaTransformation.Transformation<number, DateTime.TimeZone.Offset, never, never>;
compose: (other: SchemaTransformation.Transformation<T2, DateTime.TimeZone.Offset, RD2, RE2>) => SchemaTransformation.Transformation<T2, number, RD2, RE2>;
}
Decodes a numeric time-zone offset in milliseconds into a
DateTime.TimeZone.Offset and encodes it back to the offset number.
When to use
Use when you need a schema transformation to represent fixed-offset time
zones with numeric millisecond offsets.
Details
Decode uses DateTime.zoneMakeOffset; encode returns the offset's offset
field.
timeZoneOffsetFromNumber
),
Annotations.Declaration<DateTime.TimeZone.Offset, readonly []>.toArbitrary?: Annotations.ToArbitrary.Declaration<DateTime.TimeZone.Offset, readonly []> | undefinedtoArbitrary: () => (fc: typeof FastCheckfc) =>
fc: typeof FastCheckfc.integer({ min: numbermin: -12 * 60 * 60 * 1000, max: numbermax: 14 * 60 * 60 * 1000 }).map((n: anyn) => import DateTimeDateTime.zoneMakeOffset(n: anyn)),
Annotations.Declaration<DateTime.TimeZone.Offset, readonly []>.toFormatter?: Annotations.ToFormatter.Declaration<DateTime.TimeZone.Offset, readonly []> | undefinedtoFormatter: () => (tz: any(parameter) tz: {
_tag: "Offset";
offset: number;
toString: () => string;
toJSON: () => unknown;
}
tz) => import DateTimeDateTime.zoneToString(tz: any(parameter) tz: {
_tag: "Offset";
offset: number;
toString: () => string;
toJSON: () => unknown;
}
tz),
Annotations.Declaration<DateTime.TimeZone.Offset, readonly []>.toEquivalence?: Annotations.ToEquivalence.Declaration<DateTime.TimeZone.Offset, readonly []> | undefinedtoEquivalence: () => (a: any(parameter) a: {
_tag: "Offset";
offset: number;
toString: () => string;
toJSON: () => unknown;
}
a, b: any(parameter) b: {
_tag: "Offset";
offset: number;
toString: () => string;
toJSON: () => unknown;
}
b) => a: any(parameter) a: {
_tag: "Offset";
offset: number;
toString: () => string;
toJSON: () => unknown;
}
a.offset === b: any(parameter) b: {
_tag: "Offset";
offset: number;
toString: () => string;
toJSON: () => unknown;
}
b.offset
}
)