]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
[bugfix] remove `ordinal` for `Turkish` locale as they use `cardin… (#4361)
authorAlan Agius <alan.agius4@gmail.com>
Fri, 2 Mar 2018 19:01:04 +0000 (20:01 +0100)
committerKunal Marwaha <marwahaha@berkeley.edu>
Fri, 2 Mar 2018 19:01:04 +0000 (11:01 -0800)
* bugfix: local remove `ordinal` for `Turkish` locale as they use `cardinal` days

Closes: #4122
* restore ordinals

src/locale/tr.js
src/test/locale/tr.js

index 841eb6ccb49f94e137e2a8dd13f9ad53fdbfcac2..b5e8ad79c01e9f899cd674139517bb5f94935d8d 100644 (file)
@@ -1,3 +1,4 @@
+
 //! moment.js locale configuration
 //! locale : Turkish [tr]
 //! authors : Erhan Gundogan : https://github.com/erhangundogan,
@@ -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.
index 6fa83ac5d73213ac23753c380c9df265b6fbfde3..5d96a325b9edd0c770a48b59565ddcb785434ea1 100644 (file)
@@ -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'],
@@ -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');
 });
-