Layer.Layer<CurrentTimeZone, never, never>Create a Layer from the system's local time zone.
Details
This layer provides the CurrentTimeZone service using the system's
configured local time zone.
Example (Providing local time zone layers)
import { DateTime, Effect } from "effect"
const program = Effect.gen(function*() {
const now = yield* DateTime.nowInCurrentZone
return DateTime.formatIsoZoned(now)
})
// Use the system's local time zone
Effect.provide(program, DateTime.layerCurrentZoneLocal)export const const layerCurrentZoneLocal: Layer.Layer<CurrentTimeZone>const layerCurrentZoneLocal: {
build: (memoMap: MemoMap, scope: Scope.Scope) => Effect<Context.Context<CurrentTimeZone>, never, 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; <…;
}
Create a Layer from the system's local time zone.
Details
This layer provides the CurrentTimeZone service using the system's
configured local time zone.
Example (Providing local time zone layers)
import { DateTime, Effect } from "effect"
const program = Effect.gen(function*() {
const now = yield* DateTime.nowInCurrentZone
return DateTime.formatIsoZoned(now)
})
// Use the system's local time zone
Effect.provide(program, DateTime.layerCurrentZoneLocal)
layerCurrentZoneLocal: import LayerLayer.interface Layer<in ROut, out E = never, out RIn = never>A Layer describes how to build one or more services for dependency injection.
When to use
Use to model construction of application services for dependency injection,
especially when services have dependencies, can fail during construction, or
need scoped setup and release.
Details
A Layer<ROut, E, RIn> represents ROut as the services this layer
provides, E as the possible errors during layer construction, and RIn as
the services this layer requires as dependencies.
Layer<class CurrentTimeZoneclass CurrentTimeZone {
Service: Service;
key: Identifier;
}
Context service that supplies the ambient TimeZone for APIs that work in
the current zone, such as DateTime.setZoneCurrent and
DateTime.nowInCurrentZone.
Details
Provide it with DateTime.withCurrentZone, one of the withCurrentZone*
helpers, or one of the layerCurrentZone* layers.
Example (Accessing the current time zone service)
import { DateTime, Effect } from "effect"
const program = Effect.gen(function*() {
// Access the current time zone service
const zone = yield* DateTime.CurrentTimeZone
console.log(DateTime.zoneToString(zone))
})
// Provide a time zone
const layer = DateTime.layerCurrentZoneNamed("Europe/London")
Effect.provide(program, layer)
CurrentTimeZone> = import LayerLayer.const sync: {
<I, S>(service: Context.Key<I, S>): (
evaluate: LazyArg<S>
) => Layer<I>
<I, S>(
service: Context.Key<I, S>,
evaluate: LazyArg<Types.NoInfer<S>>
): Layer<I>
}
sync(class CurrentTimeZoneclass CurrentTimeZone {
key: Identifier;
of: (this: void, self: TimeZone) => TimeZone;
context: (self: TimeZone) => Context.Context<CurrentTimeZone>;
use: (f: (service: TimeZone) => Effect.Effect<A, E, R>) => Effect.Effect<A, E, CurrentTimeZone | R>;
useSync: (f: (service: TimeZone) => A) => Effect.Effect<A, never, CurrentTimeZone>;
Identifier: Identifier;
Service: Shape;
stack: string | undefined;
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; <…;
toString: () => string;
toJSON: () => unknown;
}
Context service that supplies the ambient TimeZone for APIs that work in
the current zone, such as DateTime.setZoneCurrent and
DateTime.nowInCurrentZone.
Details
Provide it with DateTime.withCurrentZone, one of the withCurrentZone*
helpers, or one of the layerCurrentZone* layers.
Example (Accessing the current time zone service)
import { DateTime, Effect } from "effect"
const program = Effect.gen(function*() {
// Access the current time zone service
const zone = yield* DateTime.CurrentTimeZone
console.log(DateTime.zoneToString(zone))
})
// Provide a time zone
const layer = DateTime.layerCurrentZoneNamed("Europe/London")
Effect.provide(program, layer)
CurrentTimeZone)(const zoneMakeLocal: () => TimeZone.NamedCreate a named time zone from the system's local time zone.
Details
This uses the system's configured time zone, which may vary depending
on the runtime environment.
Example (Creating local time zones)
import { DateTime } from "effect"
const localZone = DateTime.zoneMakeLocal()
console.log(DateTime.zoneToString(localZone)) // Output depends on system time zone
zoneMakeLocal)