Hyperlinkv0.8.0-beta.28

DateTime

DateTime.withDateconsteffect/DateTime.ts:2180
<A>(f: (date: Date) => A): (self: DateTime) => A
<A>(self: DateTime, f: (date: Date) => A): A

Applies a function to a JavaScript Date representing the DateTime and returns the function's result.

Details

The callback receives the time-zone-adjusted wall-clock date for DateTime.Zoned values. Use DateTime.withDateUtc when the callback should receive the UTC instant.

Example (Applying time zone adjusted Dates)

import { DateTime } from "effect"

// get the time zone adjusted date in milliseconds
DateTime.makeZonedUnsafe(0, { timeZone: "Europe/London" }).pipe(
  DateTime.withDate((date) => date.getTime())
)
mapping
export const withDate: {
  <A>(f: (date: Date) => A): (self: DateTime) => A
  <A>(self: DateTime, f: (date: Date) => A): A
} = Internal.withDate