(
options?:
| (Intl.DateTimeFormatOptions & {
readonly locale?: string | undefined
})
| undefined
): (self: DateTime) => string
(
self: DateTime,
options?:
| (Intl.DateTimeFormatOptions & {
readonly locale?: string | undefined
})
| undefined
): stringFormats a DateTime with Intl.DateTimeFormat.
Details
Unless a timeZone option is supplied, UTC values are formatted in UTC and
zoned values are formatted in their named zone or fixed-offset zone.
Fixed-offset zones depend on runtime support for offset timeZone
identifiers. When unsupported, formatting falls back to UTC with the
DateTime adjusted to the offset.
Example (Formatting DateTime values with Intl options)
import { DateTime } from "effect"
const dt = DateTime.makeZonedUnsafe("2024-06-15T14:30:00Z", {
timeZone: "Europe/London"
})
const formatted = DateTime.format(dt, {
dateStyle: "full",
timeStyle: "short",
locale: "en-US"
})
console.log(formatted) // "Saturday, June 15, 2024 at 3:30 PM"export const const format: {
(
options?:
| (Intl.DateTimeFormatOptions & {
readonly locale?: string | undefined
})
| undefined
): (self: DateTime) => string
(
self: DateTime,
options?:
| (Intl.DateTimeFormatOptions & {
readonly locale?: string | undefined
})
| undefined
): string
}
Formats a DateTime with Intl.DateTimeFormat.
Details
Unless a timeZone option is supplied, UTC values are formatted in UTC and
zoned values are formatted in their named zone or fixed-offset zone.
Fixed-offset zones depend on runtime support for offset timeZone
identifiers. When unsupported, formatting falls back to UTC with the
DateTime adjusted to the offset.
Example (Formatting DateTime values with Intl options)
import { DateTime } from "effect"
const dt = DateTime.makeZonedUnsafe("2024-06-15T14:30:00Z", {
timeZone: "Europe/London"
})
const formatted = DateTime.format(dt, {
dateStyle: "full",
timeStyle: "short",
locale: "en-US"
})
console.log(formatted) // "Saturday, June 15, 2024 at 3:30 PM"
format: {
(
options: | (Intl.DateTimeFormatOptions & {
readonly locale?: string | undefined
})
| undefined
options?:
| Intl.interface Intl.DateTimeFormatOptionsDateTimeFormatOptions & {
readonly locale?: string | undefinedlocale?: string | undefined
}
| undefined
): (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,
options: | (Intl.DateTimeFormatOptions & {
readonly locale?: string | undefined
})
| undefined
options?:
| Intl.interface Intl.DateTimeFormatOptionsDateTimeFormatOptions & {
readonly locale?: string | undefinedlocale?: string | undefined
}
| undefined
): string
} = import InternalInternal.const format: {
(
options?:
| (Intl.DateTimeFormatOptions & {
readonly locale?: Intl.LocalesArgument
})
| undefined
): (self: DateTime.DateTime) => string
(
self: DateTime.DateTime,
options?:
| (Intl.DateTimeFormatOptions & {
readonly locale?: Intl.LocalesArgument
})
| undefined
): string
}
format