Skip to content

localized-format

Imported from yugajs/extension/localized-format.

const localizedFormat: () => void;

Day.js’s localizedFormat: the LT, LTS, L, LL, LLL and LLLL tokens, and their short forms (l, ll, lll, llll), in formatting and parsing.

  • en has Day.js’s templates, other locales’ come from Intl (dateStyle and timeStyle), with 4-digit years. A locale’s formats win.
  • Parsing (with yugajs/extension/custom-parse-format, installed before or after) expands the tokens in the format first through yuga.$.parseFormat, the same as Day.js’s customParseFormat. The weekday names of LLLL are checked by its weekday tokens (unknown names are invalid).
import { localizedFormat } from "yugajs/extension/localized-format";
yuga.extend(localizedFormat);
yuga("2024-05-15T10:20").format("LLL"); // "May 15, 2024 10:20 AM"

void


const templateFor: (locale, token) => string;

The template of a token in a locale: its own formats, en’s, or Intl’s. A short form is its long one with shorter names and numbers, the same as Day.js. Built once per locale and token.

Used by yugajs/extension/locale-data (longDateFormat).

Parameter Type
locale yuga.Locale
token string

string