Hyperlinkv0.8.0-beta.28

DateTime

DateTime.layerCurrentZoneconsteffect/DateTime.ts:2833
(resource: NoInfer<TimeZone>): Layer.Layer<CurrentTimeZone>

Create a Layer from the given time zone.

Details

This layer provides the CurrentTimeZone service with the specified time zone.

Example (Providing current time zone layers)

import { DateTime, Effect } from "effect"

const zone = DateTime.zoneMakeNamedUnsafe("Europe/London")
const layer = DateTime.layerCurrentZone(zone)

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

// Use the layer to provide the time zone
Effect.provide(program, layer)
current time zone
export const layerCurrentZone: (resource: NoInfer<TimeZone>) => Layer.Layer<CurrentTimeZone> = Layer.succeed(
  CurrentTimeZone
)