# @messageformat/date-skeleton

> A parser & formatter for ICU DateFormat skeleton strings

Latest version **1.1.0** (published 2024-10-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install @messageformat/date-skeleton
pnpm add @messageformat/date-skeleton
yarn add @messageformat/date-skeleton
bun add @messageformat/date-skeleton
```

## Health

**Score 35/100 (D)** — status: maintenance-mode.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2024-10-02 |
| First published | 2020-11-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 27.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | eemeli |
| Keywords | icu, messageformat, dateformat, skeleton, parser, formatter |

## Links

- npm: https://www.npmjs.com/package/@messageformat/date-skeleton
- Repository: https://github.com/messageformat/messageformat
- Homepage: http://messageformat.github.io/messageformat/api/date-skeleton/
- Issues: https://github.com/messageformat/messageformat/issues
- npm.io page: https://npm.io/package/@messageformat/date-skeleton

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 1.1.0 (latest) — 2024-10-02
- 2.0.0-0 (next) — 2025-03-24
- 1.0.1 — 2022-07-16
- 1.0.0 — 2021-05-13
- 1.0.0-beta.1 — 2020-11-29

## README

# @messageformat/date-skeleton

Tools for working with [ICU DateFormat skeletons](http://userguide.icu-project.org/formatparse/datetime)<!-- -->.

```js
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](https://www.npmjs.com/package/esm)<!-- -->.

Uses [Intl.DateTimeFormat](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat) internally. Position-dependent ICU DateFormat [patterns](https://unicode.org/reports/tr35/tr35-dates.html#Date_Format_Patterns) are not supported, as they cannot be represented with Intl.DateTimeFormat options.

## Classes

| Class                                                                                               | Description              |
| --------------------------------------------------------------------------------------------------- | ------------------------ |
| [DateFormatError](https://messageformat.github.io/messageformat/api/date-skeleton.dateformaterror/) | Parent class for errors. |

## Functions

| Function                                                                                                                                              | Description                                                                                                                                                                                                                                                                                                                                            |
| ----------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| [getDateFormatter(locales, tokens, onError)](https://messageformat.github.io/messageformat/api/date-skeleton.getdateformatter/)                       | Returns a date formatter function for the given locales and date skeleton                                                                                                                                                                                                                                                                              |
| [getDateFormatter(locales, tokens, timeZone, onError)](https://messageformat.github.io/messageformat/api/date-skeleton.getdateformatter/)             | Returns a date formatter function for the given locales and date skeleton with time zone overrride.                                                                                                                                                                                                                                                    |
| [getDateFormatterSource(locales, tokens, onError)](https://messageformat.github.io/messageformat/api/date-skeleton.getdateformattersource/)           | Returns a string of JavaScript source that evaluates to a date formatter function with the same <code>(date: Date &#124; number) =&gt; string</code> signature as the function returned by [getDateFormatter()](https://github.com/messageformat/messageformat/blob/main/docs/api/date-skeleton.getdateformatter.md)<!-- -->.                          |
| [getDateFormatterSource(locales, tokens, timeZone, onError)](https://messageformat.github.io/messageformat/api/date-skeleton.getdateformattersource/) | Returns a string of JavaScript source that evaluates to a date formatter function with the same <code>(date: Date &#124; number) =&gt; string</code> signature as the function returned by [getDateFormatter()](https://github.com/messageformat/messageformat/blob/main/docs/api/date-skeleton.getdateformatter.md) with time zone override <!-- -->. |
| [parseDateTokens(src)](https://messageformat.github.io/messageformat/api/date-skeleton.parsedatetokens/)                                              | Parse an [ICU DateFormat skeleton](http://userguide.icu-project.org/formatparse/datetime) string into a [DateToken](https://github.com/messageformat/messageformat/blob/main/docs/api/date-skeleton.datetoken.md) array.                                                                                                                               |

## Type Aliases

| Type Alias                                                                              | Description                                              |
| --------------------------------------------------------------------------------------- | -------------------------------------------------------- |
| [DateToken](https://messageformat.github.io/messageformat/api/date-skeleton.datetoken/) | An object representation of a parsed date skeleton token |

---

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

[messageformat]: https://messageformat.github.io/
[code of conduct]: https://code-of-conduct.openjsf.org/

<a href="https://openjsf.org">
<img width=200 alt="OpenJS Foundation" src="https://messageformat.github.io/messageformat/logo/openjsf.svg" />
</a>

---
_Source: https://npm.io/package/@messageformat/date-skeleton · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
