Skip to main content
Module

x/complaindate/mod.ts>formatPlainDate

JavaScript date-time utilities that keep timezones on the surface
Latest
function formatPlainDate
import { formatPlainDate } from "https://deno.land/x/complaindate@v1.0.1/mod.ts";

Curry a function to get localized strings of its plain-date arguments.

The function is curried in 2 rounds, each setting a property:

  1. Intl locale, defaults to system's locale if not given.
  2. Intl format options, defaults to "short" date-style if no options given.

Examples

Example 1

const formatDate = formatPlainDate()(); // Use system's locale and default formatting options
const formatMonthAndDay = formatPlainDate("en")({ month: "long", day: "numeric" });

formatDate(PlainDate({ year: 2023 })); // "1/1/2023"
formatMonthAndDay(PlainDate({ year: 2023 }));  // "January 1"

Parameters

optional
locale: Intl.LocalesArgument

Intl locale

Returns

(options?: FormatPlainDateOptions) => (date: ComPlainDate) => string

A curried function that takes Intl format options and returns the final curried function that operates on plain-dates