(format: Intl.DateTimeFormat): (self: DateTime) => string
(self: DateTime, format: Intl.DateTimeFormat): stringFormats a DateTime as a string using the Intl.DateTimeFormat API.
When to use
Use when you already have an Intl.DateTimeFormat and want it to control the
locale, time zone, and formatting options.
Details
The formatter receives the DateTime epoch milliseconds. Any time zone
conversion comes from the supplied formatter.
Example (Formatting DateTime values with custom formatters)
import { DateTime } from "effect"
const dt = DateTime.makeUnsafe("2024-06-15T14:30:00Z")
// Create a custom formatter
const formatter = new Intl.DateTimeFormat("de-DE", {
year: "numeric",
month: "long",
day: "numeric",
hour: "2-digit",
minute: "2-digit",
timeZone: "Europe/Berlin"
})
const formatted = DateTime.formatIntl(dt, formatter)
console.log(formatted.length > 0) // trueexport const const formatIntl: {
(format: Intl.DateTimeFormat): (
self: DateTime
) => string
(
self: DateTime,
format: Intl.DateTimeFormat
): string
}
Formats a DateTime as a string using the Intl.DateTimeFormat API.
When to use
Use when you already have an Intl.DateTimeFormat and want it to control the
locale, time zone, and formatting options.
Details
The formatter receives the DateTime epoch milliseconds. Any time zone
conversion comes from the supplied formatter.
Example (Formatting DateTime values with custom formatters)
import { DateTime } from "effect"
const dt = DateTime.makeUnsafe("2024-06-15T14:30:00Z")
// Create a custom formatter
const formatter = new Intl.DateTimeFormat("de-DE", {
year: "numeric",
month: "long",
day: "numeric",
hour: "2-digit",
minute: "2-digit",
timeZone: "Europe/Berlin"
})
const formatted = DateTime.formatIntl(dt, formatter)
console.log(formatted.length > 0) // true
formatIntl: {
(format: Intl.DateTimeFormatformat: Intl.interface Intl.DateTimeFormatDateTimeFormat): (self: DateTimeself: 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) => string
(self: DateTimeself: 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, format: Intl.DateTimeFormatformat: Intl.interface Intl.DateTimeFormatDateTimeFormat): string
} = import InternalInternal.const formatIntl: {
(format: Intl.DateTimeFormat): (
self: DateTime.DateTime
) => string
(
self: DateTime.DateTime,
format: Intl.DateTimeFormat
): string
}
formatIntl