Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New token LD for localized day of month #4277

Closed
fbonzon opened this issue Oct 29, 2017 · 1 comment
Closed

New token LD for localized day of month #4277

fbonzon opened this issue Oct 29, 2017 · 1 comment

Comments

@fbonzon
Copy link
Contributor

fbonzon commented Oct 29, 2017

Follow-up to #3375 in a new issue, with a summary of current proposition.

The tokens used to format a moment based on its locale LT LTS L l LL lll LLL lll LLLL llll are configured in the source code with a fixed string of sub-tokens, independently of the actual moment being formatted.

This is unfortunately insufficient to express how dates and times should be formatted in some locales. The sub-tokens to use can vary with the actual date or time being formatted.

Example is French, where the way to pronounce and write day of month depends on the actual day of month. It is an ordinal for 1 and a cardinal for 2+. E.g. correct sub-tokens for LLL are:

  • When day of month = 1: Do MMMM YYYY HH:mm
  • Otherwise: D MMMM YYYY HH:mm

Current code has to choose one of the two (for instance second one), and gets the date improperly formatted in about 1/30 cases.

I suggest to introduce new token LD.
By default, it has the same value as Do.
Locales can then refine. French locale would for example define:
LD: value of Do when day of month being formatted = 1, value of D otherwise
LLL: LD MMMM YYYY HH:mm

Other ideas to implement this problem ?

@ichernev
Copy link
Contributor

@fbonzon I skimmed over #3375, but I'm afraid we do not want to add yet another token to all locales to fix a particular locale weirdness.

What I am more open to is provide more "hook/plugin" points for locales that do want to do something crazy to be able to (like preparse and postformat). Actually this particular issue might be solved with postformat (although ugly).

Option 1 from #3375 is more in-line with what I'm talking about. Sadly option 2 is easier, but the locale-related code-creep in moment is just unmanageable any more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants