1. @messageformat/date-skeleton
A parser & formatter for ICU DateFormat skeleton strings
@messageformat/date-skeleton
Package: @messageformat/date-skeleton
Created by: messageformat
Last modified: Sat, 16 Jul 2022 18:41:44 GMT
Version: 1.0.1
License: MIT
Downloads: 1,444,306
Repository: https://github.com/messageformat/messageformat

Install

npm install @messageformat/date-skeleton
yarn add @messageformat/date-skeleton

@messageformat/date-skeleton

Tools for working with ICU DateFormat skeletons.

 import {
  DateFormatError,
  DateToken, // TS only
  getDateFormatter,
  getDateFormatterSource,
  parseDateTokens
} from '@messageformat/date-skeleton';

The package is released as an ES module only. If using from a CommonJS context, you may need to import() it, or use a module loader like esm.

Uses Intl.DateTimeFormat internally. Position-dependent ICU DateFormat patterns are not supported, as they cannot be represented with Intl.DateTimeFormat options.

Classes

Class Description
DateFormatError Parent class for errors.

Functions

Function Description
getDateFormatter(locales, tokens, onError) Returns a date formatter function for the given locales and date skeleton
getDateFormatterSource(locales, tokens, onError) Returns a string of JavaScript source that evaluates to a date formatter function with the same (date: Date | number) => string signature as the function returned by getDateFormatter().
parseDateTokens(src) Parse an ICU DateFormat skeleton string into a DateToken array.

Type Aliases

Type Alias Description
DateToken An object representation of a parsed date skeleton token

Messageformat is an OpenJS Foundation project, and we follow its Code of Conduct.

OpenJS Foundation

RELATED POST

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code