(
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 }
): AModifies 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"export const 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
}
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"
mutate: {
(
f: (date: Date) => voidf: (date: Datedate: Date) => void,
options: {
readonly disambiguation?:
| Disambiguation
| undefined
}
options?: {
readonly disambiguation?: Disambiguation | undefineddisambiguation?: type Disambiguation =
| "compatible"
| "earlier"
| "later"
| "reject"
A Disambiguation is used to resolve ambiguities when a DateTime is
ambiguous, such as during a daylight saving time transition.
Details
For more information, see the Temporal documentation
-
"compatible": (default) Behavior matching Temporal API and legacy JavaScript Date and moment.js.
For repeated times, chooses the earlier occurrence. For gap times, chooses the later interpretation.
-
"earlier": For repeated times, always choose the earlier occurrence.
For gap times, choose the time before the gap.
-
"later": For repeated times, always choose the later occurrence.
For gap times, choose the time after the gap.
-
"reject": Throw an RangeError when encountering ambiguous or non-existent times.
Example (Resolving ambiguous local times)
import { DateTime } from "effect"
// Fall-back example: 01:30 on Nov 2, 2025 in New York happens twice
const ambiguousTime = { year: 2025, month: 11, day: 2, hours: 1, minutes: 30 }
const timeZone = DateTime.zoneMakeNamedUnsafe("America/New_York")
DateTime.makeZoned(ambiguousTime, {
timeZone,
adjustForTimeZone: true,
disambiguation: "earlier"
})
// Earlier occurrence (DST time): 2025-11-02T05:30:00.000Z
DateTime.makeZoned(ambiguousTime, {
timeZone,
adjustForTimeZone: true,
disambiguation: "later"
})
// Later occurrence (standard time): 2025-11-02T06:30:00.000Z
// Gap example: 02:30 on Mar 9, 2025 in New York doesn't exist
const gapTime = { year: 2025, month: 3, day: 9, hours: 2, minutes: 30 }
DateTime.makeZoned(gapTime, {
timeZone,
adjustForTimeZone: true,
disambiguation: "earlier"
})
// Time before gap: 2025-03-09T06:30:00.000Z (01:30 EST)
DateTime.makeZoned(gapTime, {
timeZone,
adjustForTimeZone: true,
disambiguation: "later"
})
// Time after gap: 2025-03-09T07:30:00.000Z (03:30 EDT)
Disambiguation | undefined
}
): <function (type parameter) A in <A extends DateTime>(self: A): AA extends type DateTime = Utc | ZonedA DateTime represents a point in time. It can optionally have a time zone
associated with it.
Companion namespace containing the public helper types used by DateTime
constructors, parts APIs, formatting, and date/time arithmetic.
DateTime>(self: A extends DateTimeself: function (type parameter) A in <A extends DateTime>(self: A): AA) => function (type parameter) A in <A extends DateTime>(self: A): AA
<function (type parameter) A in <A extends DateTime>(self: A, f: (date: Date) => void, options?: {
readonly disambiguation?: Disambiguation | undefined;
}): A
A extends type DateTime = Utc | ZonedA DateTime represents a point in time. It can optionally have a time zone
associated with it.
Companion namespace containing the public helper types used by DateTime
constructors, parts APIs, formatting, and date/time arithmetic.
DateTime>(
self: A extends DateTimeself: function (type parameter) A in <A extends DateTime>(self: A, f: (date: Date) => void, options?: {
readonly disambiguation?: Disambiguation | undefined;
}): A
A,
f: (date: Date) => voidf: (date: Datedate: Date) => void,
options: {
readonly disambiguation?:
| Disambiguation
| undefined
}
options?: {
readonly disambiguation?: Disambiguation | undefineddisambiguation?: type Disambiguation =
| "compatible"
| "earlier"
| "later"
| "reject"
A Disambiguation is used to resolve ambiguities when a DateTime is
ambiguous, such as during a daylight saving time transition.
Details
For more information, see the Temporal documentation
-
"compatible": (default) Behavior matching Temporal API and legacy JavaScript Date and moment.js.
For repeated times, chooses the earlier occurrence. For gap times, chooses the later interpretation.
-
"earlier": For repeated times, always choose the earlier occurrence.
For gap times, choose the time before the gap.
-
"later": For repeated times, always choose the later occurrence.
For gap times, choose the time after the gap.
-
"reject": Throw an RangeError when encountering ambiguous or non-existent times.
Example (Resolving ambiguous local times)
import { DateTime } from "effect"
// Fall-back example: 01:30 on Nov 2, 2025 in New York happens twice
const ambiguousTime = { year: 2025, month: 11, day: 2, hours: 1, minutes: 30 }
const timeZone = DateTime.zoneMakeNamedUnsafe("America/New_York")
DateTime.makeZoned(ambiguousTime, {
timeZone,
adjustForTimeZone: true,
disambiguation: "earlier"
})
// Earlier occurrence (DST time): 2025-11-02T05:30:00.000Z
DateTime.makeZoned(ambiguousTime, {
timeZone,
adjustForTimeZone: true,
disambiguation: "later"
})
// Later occurrence (standard time): 2025-11-02T06:30:00.000Z
// Gap example: 02:30 on Mar 9, 2025 in New York doesn't exist
const gapTime = { year: 2025, month: 3, day: 9, hours: 2, minutes: 30 }
DateTime.makeZoned(gapTime, {
timeZone,
adjustForTimeZone: true,
disambiguation: "earlier"
})
// Time before gap: 2025-03-09T06:30:00.000Z (01:30 EST)
DateTime.makeZoned(gapTime, {
timeZone,
adjustForTimeZone: true,
disambiguation: "later"
})
// Time after gap: 2025-03-09T07:30:00.000Z (03:30 EDT)
Disambiguation | undefined
}
): function (type parameter) A in <A extends DateTime>(self: A, f: (date: Date) => void, options?: {
readonly disambiguation?: Disambiguation | undefined;
}): A
A
} = import InternalInternal.const mutate: {
(
f: (date: Date) => void,
options?: {
readonly disambiguation?:
| DateTime.Disambiguation
| undefined
}
): <A extends DateTime.DateTime>(self: A) => A
<A extends DateTime.DateTime>(
self: A,
f: (date: Date) => void,
options?: {
readonly disambiguation?:
| DateTime.Disambiguation
| undefined
}
): A
}
mutate