-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Why we may need it?
Currently in @gravity-ui/date-utils a moment-like format is used. Using this approach has several disadvantages:
- To implement this approach, it's necessary to have separate files for each locale, for example, this is how it looks in dayjs, which we use in our library. This directory contains 142 files, each up to ~100 lines of code, which makes loading locales in date-utils happen asynchronously.
- When using moment-like format, you cannot use standalone tokens. For example, the format
'D MMMM'inrulocale will always return'25 Февраля'because it uses complex logic that needs to be repeated for each locale.
Within this RFC, it is proposed to switch to using the Unicode Technical Standard #35 format. Below I suggest we consider its advantages and disadvantages and decide whether we want to switch to it.
Advantages:
- Using Intl for translating date tokens
- This is a big step towards abandoning dayjs
- Using standalone tokens
'd MMMM' // 25 февраля 'd LLLL' // 25 февраль
- No need to load required locales when using (if not using
humanize durationorordinal dates) - Using a generally accepted standard
Disadvantages:
-
Changing the familiar format. Let's imagine it's 25.02.2025 and we call the method
dateTime().format(format)in our browser, whereformatis a pattern from the table below:Moment-like UTS Add support for generic in value prop to Select in gravity-ui #35 based Result D d 25 YYYY yyyy 2025 DD.MM.YYYY dd.MM.yyyy 25.02.2025 L P 02/25/2025 The full difference in formats can be seen at these links: Moment-like | UTS #35 based
-
We will have to describe
humanize durationandordinal datesourselves for each locale, here's an example for therulocale. This part of localization will have to be loaded asynchronously (just as it is done now for all locales)
Metadata
Metadata
Assignees
Labels
Type
Projects
Status