import { formatInstant } from "https://deno.land/x/complaindate@v0.7.2/utils/formatInstant.ts";
Curry a function to get localized strings of its JS Date
arguments.
The function is curried in 3 rounds, each setting a property:
Intl
locale, defaults to system's locale if not given.Intl
format options, defaults to include a "short" timezone-style unlesstimeZoneName
is explicitlyundefined
.- A named IANA timezone, defaults to system's timezone if not given.
Examples
Example 1
Example 1
const formatDateTime = formatInstant()()("Europe/Stockholm"); // Use system's locale and default formatting options
const format24hDateTime = formatInstant("en")({ hourCycle: "h23" })("Europe/Stockholm");
formatDateTime(new Date()); // "6/11/2023, 4:54:32 PM GMT+2"
format24hDateTime(new Date()); // "6/11/2023, 16:54:32 GMT+2"
Returns
(options?: FormatInstantOptions) => (timezone?: string) => (instant: Date) => string
A curried function that takes Intl
format options and returns another curried function that takes a timezone and returns the final curried function that operates on JS Date
objects