Package: effect
Module: DateTime
Modifies a DateTime with a mutable local Date copy.
When to use
Use to adjust calendar fields in the DateTime’s own time zone with an
existing Date mutation API.
Details
The Date will first have the time zone applied if possible, and then be
converted back to a DateTime within the same time zone.
Supports disambiguation when the new wall clock time is ambiguous.
Example (Mutating DateTime values with Dates)
import { DateTime } from "effect"
const dt = DateTime.makeUnsafe("2024-01-01T12:00:00Z")
const modified = DateTime.mutate(dt, (date) => {
date.setHours(15) // Set to 3 PM
date.setMinutes(30) // Set to 30 minutes
})
console.log(DateTime.formatIso(modified)) // "2024-01-01T15:30:00.000Z"
Signature
declare const mutate: { (f: (date: Date) => void, options?: { readonly disambiguation?: Disambiguation | undefined; }): <A extends DateTime>(self: A) => A; <A extends DateTime>(self: A, f: (date: Date) => void, options?: { readonly disambiguation?: Disambiguation | undefined; }): A; }
Since v3.6.0