0.2.0 • Published 5 months ago

format-temporal v0.2.0

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
5 months ago

format-temporal

A formatting function for Temporal types.

Motivation

Several Temporal types don't support the toLocaleString method (i.e., Temporal.ZonedDateTime, Temporal.PlainYearMonth, and Temporal.PlainMonthDay), so this package provides a formatTemporal function that formats a Temporal type using the Intl.DateTimeFormat API.

Usage

import { formatTemporal } from "format-temporal";

const plainYearMonth = Temporal.PlainYearMonth.from("2023-05");
const formatter = new Intl.DateTimeFormat("en-US", {
  year: "numeric",
  month: "long",
});
const result = formatTemporal(plainYearMonth, formatter);
console.log(result); // "May 2023"

License

Apache-2.0

0.2.0

5 months ago

0.1.0

6 months ago

0.0.1

7 months ago