Date

April 27, 2026 ยท View on GitHub

License Stable Downloads JavaScript npm Issues Merge Requests

Description

Date formatting helpers for Enso UI.

Installation

Install the package:

yarn add @enso-ui/date

Features

  • formats absolute dates using PHP-style Enso format strings
  • formats relative distances with locale-aware date-fns translations
  • ships the locale map used by the date helpers
  • converts Enso/PHP date tokens to date-fns Unicode tokens

Usage

import format from '@enso-ui/date/src/format';
import formatDistance from '@enso-ui/date/src/formatDistance';

format('2026-04-21', 'd.m.Y', 'ro');
formatDistance('2026-04-20', 'en');

API

format(date, formatStr, locale = 'en')

Formats a date using PHP-style tokens.

Import: @enso-ui/date/src/format.js

formatDistance(date, locale = 'en')

Formats a relative distance from now.

Import: @enso-ui/date/src/formatDistance.js

i18n

Locale map used by the date helpers.

Import: @enso-ui/date/src/i18n.js

unicode2php(formatStr)

Converts Enso/PHP date tokens to the date-fns token set used internally.

Import: @enso-ui/date/src/unicode2php.js

Depends On

Contributions

are welcome. Pull requests are great, but issues are good too.

Thank you to all the people who already contributed to Enso!

License

MIT