Hyperlinkv0.8.0-beta.28

DateTime

DateTime.layerCurrentZoneNamedconsteffect/DateTime.ts:2892
(zoneId: string): Layer.Layer<CurrentTimeZone, IllegalArgumentError>

Create a Layer from the given IANA time zone identifier.

Details

This layer provides the CurrentTimeZone service with a named time zone. If the time zone identifier is invalid, the layer will fail.

Example (Providing named time zone layers)

import { DateTime, Effect } from "effect"

const layer = DateTime.layerCurrentZoneNamed("Europe/London")

const program = Effect.gen(function*() {
  const now = yield* DateTime.nowInCurrentZone
  return DateTime.formatIsoZoned(now)
})

Effect.provide(program, layer)
current time zone
export const layerCurrentZoneNamed: (zoneId: string) => Layer.Layer<
  CurrentTimeZone,
  IllegalArgumentError
> = flow(Internal.zoneMakeNamedEffect, Layer.effect(CurrentTimeZone))