Hyperlinkv0.8.0-beta.28

DateTime

DateTime.CurrentTimeZoneclasseffect/DateTime.ts:1889
CurrentTimeZone

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)
current time zone
export class CurrentTimeZone extends Context.Service<CurrentTimeZone, TimeZone>()(
  "effect/DateTime/CurrentTimeZone"
) {}
Referenced by 10 symbols