Skip to content

Commit

Permalink
[bugfix] remove ordinal for Turkish locale as they use `cardin… (#…
Browse files Browse the repository at this point in the history
…4361)

* bugfix: local remove `ordinal` for `Turkish` locale as they use `cardinal` days

Closes: #4122

* restore ordinals
  • Loading branch information
alan-agius4 authored and marwahaha committed Mar 2, 2018
1 parent 1860a7a commit 0fe46e4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
24 changes: 16 additions & 8 deletions src/locale/tr.js
@@ -1,3 +1,4 @@

//! moment.js locale configuration
//! locale : Turkish [tr]
//! authors : Erhan Gundogan : https://github.com/erhangundogan,
Expand Down Expand Up @@ -64,15 +65,22 @@ export default moment.defineLocale('tr', {
y : 'bir yıl',
yy : '%d yıl'
},
dayOfMonthOrdinalParse: /\d{1,2}'(inci|nci|üncü|ncı|uncu|ıncı)/,
ordinal : function (number) {
if (number === 0) { // special case for zero
return number + '\'ıncı';
ordinal: function (number, period) {
switch (period) {
case 'd':
case 'D':
case 'Do':
case 'DD':
return number;
default:
if (number === 0) { // special case for zero
return number + '\'ıncı';
}
var a = number % 10,
b = number % 100 - a,
c = number >= 100 ? 100 : null;
return number + (suffixes[a] || suffixes[b] || suffixes[c]);
}
var a = number % 10,
b = number % 100 - a,
c = number >= 100 ? 100 : null;
return number + (suffixes[a] || suffixes[b] || suffixes[c]);
},
week : {
dow : 1, // Monday is the first day of the week.
Expand Down
7 changes: 3 additions & 4 deletions src/test/locale/tr.js
Expand Up @@ -22,12 +22,12 @@ test('parse', function (assert) {

test('format', function (assert) {
var a = [
['dddd, MMMM Do YYYY, h:mm:ss a', 'Pazar, Şubat 14\'üncü 2010, 3:25:50 pm'],
['dddd, MMMM Do YYYY, h:mm:ss a', 'Pazar, Şubat 14 2010, 3:25:50 pm'],
['ddd, hA', 'Paz, 3PM'],
['M Mo MM MMMM MMM', '2 2\'nci 02 Şubat Şub'],
['YYYY YY', '2010 10'],
['D Do DD', '14 14\'üncü 14'],
['d do dddd ddd dd', '0 0\'ıncı Pazar Paz Pz'],
['D Do DD', '14 14 14'],
['d do dddd ddd dd', '0 0 Pazar Paz Pz'],
['DDD DDDo DDDD', '45 45\'inci 045'],
['w wo ww', '7 7\'nci 07'],
['h hh', '3 03'],
Expand Down Expand Up @@ -217,4 +217,3 @@ test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2\'nci', 'Jan 8 2012 should be week 2');
assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3\'üncü', 'Jan 9 2012 should be week 3');
});

0 comments on commit 0fe46e4

Please sign in to comment.