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

[locale] fr-ca: Match fr for ordinals #6110

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 7 additions & 2 deletions locale/fr-ca.js
Expand Up @@ -56,14 +56,19 @@
y: 'un an',
yy: '%d ans',
},
dayOfMonthOrdinalParse: /\d{1,2}(er|e)/,
dayOfMonthOrdinalParse: /\d{1,2}(er|)/,
ordinal: function (number, period) {
switch (period) {
// TODO: Return 'e' when day of month > 1. Move this case inside
// block for masculine words below.
// See https://github.com/moment/moment/issues/3375
case 'D':
return number + (number === 1 ? 'er' : '');

// Words with masculine grammatical gender: mois, trimestre, jour
default:
case 'M':
case 'Q':
case 'D':
case 'DDD':
case 'd':
return number + (number === 1 ? 'er' : 'e');
Expand Down
9 changes: 7 additions & 2 deletions src/locale/fr-ca.js
Expand Up @@ -49,14 +49,19 @@ export default moment.defineLocale('fr-ca', {
y: 'un an',
yy: '%d ans',
},
dayOfMonthOrdinalParse: /\d{1,2}(er|e)/,
dayOfMonthOrdinalParse: /\d{1,2}(er|)/,
ordinal: function (number, period) {
switch (period) {
// TODO: Return 'e' when day of month > 1. Move this case inside
// block for masculine words below.
// See https://github.com/moment/moment/issues/3375
case 'D':
return number + (number === 1 ? 'er' : '');

// Words with masculine grammatical gender: mois, trimestre, jour
default:
case 'M':
case 'Q':
case 'D':
case 'DDD':
case 'd':
return number + (number === 1 ? 'er' : 'e');
Expand Down
8 changes: 4 additions & 4 deletions src/test/locale/fr-ca.js
Expand Up @@ -50,12 +50,12 @@ test('format', function (assert) {
var a = [
[
'dddd, MMMM Do YYYY, h:mm:ss a',
'dimanche, février 14e 2010, 3:25:50 pm',
'dimanche, février 14 2010, 3:25:50 pm',
],
['ddd, hA', 'dim., 3PM'],
['M Mo MM MMMM MMM', '2 2e 02 février févr.'],
['YYYY YY', '2010 10'],
['D Do DD', '14 14e 14'],
['D Do DD', '14 14 14'],
['d do dddd ddd dd', '0 0e dimanche dim. di'],
['DDD DDDo DDDD', '45 45e 045'],
['w wo ww', '8 8e 08'],
Expand All @@ -64,7 +64,7 @@ test('format', function (assert) {
['m mm', '25 25'],
['s ss', '50 50'],
['a A', 'pm PM'],
['[le] Do [jour du mois]', 'le 14e jour du mois'],
['[le] Do [jour du mois]', 'le 14 jour du mois'],
['[le] DDDo [jour de l’année]', 'le 45e jour de l’année'],
['LTS', '15:25:50'],
['L', '2010-02-14'],
Expand Down Expand Up @@ -92,7 +92,7 @@ test('format ordinal', function (assert) {
assert.equal(moment([2017, 3, 1]).format('Qo'), '2e', '2e');

assert.equal(moment([2017, 0, 1]).format('Do'), '1er', '1er');
assert.equal(moment([2017, 0, 2]).format('Do'), '2e', '2e');
assert.equal(moment([2017, 0, 2]).format('Do'), '2', '2');

assert.equal(moment([2011, 0, 1]).format('DDDo'), '1er', '1er');
assert.equal(moment([2011, 0, 2]).format('DDDo'), '2e', '2e');
Expand Down