A parser & formatter for ICU DateFormat skeleton strings

Downloads in past


1,580151.0.12 months ago2 years agoMinified + gzip package size for @messageformat/date-skeleton in KB


Tools for working with ICU DateFormat skeletons.
import {
  DateToken, // TS only
} 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.


| Class | Description | | ----------------------------------------------------------------------------------------------------------------------------- | ------------------------ | | DateFormatError | Parent class for errors. |


| 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