Skip to content

fix(locale): use correct English ordinal in en-ca, en-ie, en-il, en-sg#3152

Open
greymoth-jp wants to merge 1 commit into
iamkun:devfrom
greymoth-jp:fix/en-variant-ordinal
Open

fix(locale): use correct English ordinal in en-ca, en-ie, en-il, en-sg#3152
greymoth-jp wants to merge 1 commit into
iamkun:devfrom
greymoth-jp:fix/en-variant-ordinal

Conversation

@greymoth-jp

Copy link
Copy Markdown

What

en-ca, en-ie, en-il and en-sg still carry the placeholder ordinal: n => n, so format('Do') returns the bare day number for them:

dayjs('2021-01-21').locale('en-au').format('Do') // "21st"
dayjs('2021-01-21').locale('en-ca').format('Do') // "21"  (expected "21st")

(Do comes from the advancedFormat plugin.)

The other English locales already define the standard English ordinal function: en, en-au, en-gb, en-in, en-nz, en-tt. English ordinals (1st/2nd/3rd, 11th/21st) are the same across these regions, so the four locales above were simply missing the function rather than intentionally different. This is the same change #2878 made for en-au ("Use the same ordinal as moment"); moment also defines the full ordinal for en-ca, en-ie, en-il and en-sg.

Fix

Reuse the existing English ordinal function in the four locales.

Test

Added an ordinal parity check in test/locale/en.test.js that compares format('Do') against moment for days 1 to 31 in each of the four locales. It fails on the old n => n and passes with the change. The full jest suite is green and eslint passes.

These four English-variant locales kept the placeholder ordinal n => n, so
format('Do') returned the bare day number ("21" instead of "21st"). The
other English locales (en, en-au, en-gb, en-in, en-nz, en-tt) already use
the standard English ordinal function; reuse it here so all English
variants agree. Matches moment's ordinal for these locales (see iamkun#2878).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant