(self: DateTime): Effect.Effect<Zoned, never, CurrentTimeZone>Sets the time zone of a DateTime to the current time zone, which is
determined by the CurrentTimeZone service.
Example (Setting the current time zone)
import { DateTime, Effect } from "effect"
Effect.gen(function*() {
const now = yield* DateTime.now
// set the time zone to "Europe/London"
const zoned = yield* DateTime.setZoneCurrent(now)
}).pipe(DateTime.withCurrentZoneNamed("Europe/London"))export const const setZoneCurrent: (
self: DateTime
) => Effect.Effect<Zoned, never, CurrentTimeZone>
Sets the time zone of a DateTime to the current time zone, which is
determined by the CurrentTimeZone service.
Example (Setting the current time zone)
import { DateTime, Effect } from "effect"
Effect.gen(function*() {
const now = yield* DateTime.now
// set the time zone to "Europe/London"
const zoned = yield* DateTime.setZoneCurrent(now)
}).pipe(DateTime.withCurrentZoneNamed("Europe/London"))
setZoneCurrent = (self: DateTimeself: type DateTime = Utc | ZonedA DateTime represents a point in time. It can optionally have a time zone
associated with it.
Companion namespace containing the public helper types used by DateTime
constructors, parts APIs, formatting, and date/time arithmetic.
DateTime): import EffectEffect.interface Effect<out A, out E = never, out R = never>The Effect interface defines a value that lazily describes a workflow or
job. The workflow requires some context R, and may fail with an error of
type E, or succeed with a value of type A.
When to use
Use when you need to represent a lazy, composable workflow that can require
services, fail with a typed error, or succeed with a typed value.
Details
Effect values model resourceful interaction with the outside world,
including synchronous, asynchronous, concurrent, and parallel interaction.
They use a fiber-based concurrency model, with built-in support for
scheduling, fine-grained interruption, structured concurrency, and high
scalability.
To run an Effect value, you need a Runtime, which is a type that is
capable of executing Effect values.
Effect<Zoned, never, 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 EffectEffect.const map: {
<A, B>(f: (a: A) => B): <E, R>(
self: Effect<A, E, R>
) => Effect<B, E, R>
<A, E, R, B>(
self: Effect<A, E, R>,
f: (a: A) => B
): Effect<B, E, R>
}
map(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, (zone: TimeZonezone) => const setZone: {
(
zone: TimeZone,
options?: {
readonly adjustForTimeZone?:
| boolean
| undefined
readonly disambiguation?:
| Disambiguation
| undefined
}
): (self: DateTime) => Zoned
(
self: DateTime,
zone: TimeZone,
options?: {
readonly adjustForTimeZone?:
| boolean
| undefined
readonly disambiguation?:
| Disambiguation
| undefined
}
): Zoned
}
setZone(self: DateTimeself, zone: TimeZonezone))