]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
Adding AM/PM support for Russian and Ukrainian
authorMenelion Elensúle (Andre Polykanine) <andre@oire.org>
Thu, 12 Sep 2013 21:38:50 +0000 (00:38 +0300)
committerMenelion Elensúle (Andre Polykanine) <andre@oire.org>
Thu, 12 Sep 2013 21:38:50 +0000 (00:38 +0300)
lang/ru.js
lang/uk.js
test/lang/ru.js
test/lang/uk.js

index a896eaa4bea0d57f08642cd3c59c71c2c6253d04..b7ebc7f631b75a2f590a8818617365e3a98b3dea 100644 (file)
             yy : relativeTimeWithPlural
         },
 
+        // M. E.: those two are virtually unused but a user might want to implement them for his/her website for some reason
+
+        meridiem : function (hour, minute, isLower) {
+            if (hour >= 0 && hour < 4) {
+                return "ночи";
+            } else if (hour >= 4 && hour < 12) {
+                return "утра";
+            } else if (hour >= 12 && hour < 17) {
+                return "дня";
+            } else {
+                return "вечера";
+            }
+        },
+
         ordinal: function (number, period) {
             switch (period) {
             case 'M':
index 905f81a07b586b654347f62d6efaa48394e9adbd..2a5bc8ca2e8b9e20ad4da8aa4364070ee0cdb989 100644 (file)
             y : "рік",
             yy : relativeTimeWithPlural
         },
+
+        // M. E.: those two are virtually unused but a user might want to implement them for his/her website for some reason
+
+        meridiem : function (hour, minute, isLower) {
+            if (hour >= 0 && hour < 4) {
+                return "ночі";
+            } else if (hour >= 4 && hour < 12) {
+                return "ранку";
+            } else if (hour >= 12 && hour < 17) {
+                return "дня";
+            } else {
+                return "вечора";
+            }
+        },
+
         ordinal: function (number, period) {
             switch (period) {
             case 'M':
index 703337fe31018ee9dd77f02db52628d7b0d41c0b..d8b4476a122bc3eb511bf6686b15b26b22be57e9 100644 (file)
@@ -42,7 +42,7 @@ exports["lang:ru"] = {
 
         var a = [
                 ['dddd, Do MMMM YYYY, HH:mm:ss',       'воскресенье, 14-го февраля 2010, 15:25:50'],
-                ['ddd, hA',                            'вск, 3PM'],
+                ['ddd, h A',                           'вск, 3 дня'],
                 ['M Mo MM MMMM MMM',                   '2 2-й 02 февраль фев'],
                 ['YYYY YY',                            '2010 10'],
                 ['D Do DD',                            '14 14-го 14'],
@@ -53,7 +53,7 @@ exports["lang:ru"] = {
                 ['H HH',                               '15 15'],
                 ['m mm',                               '25 25'],
                 ['s ss',                               '50 50'],
-                ['a A',                                'pm PM'],
+                ['a A',                                'дня дня'],
                 ['DDDo [день года]',                   '45-й день года'],
                 ['L',                                  '14.02.2010'],
                 ['LL',                                 '14 февраля 2010 г.'],
@@ -72,6 +72,21 @@ exports["lang:ru"] = {
         test.done();
     },
 
+    "format meridiem" : function (test) {
+        test.expect(8);
+
+        test.equal(moment([2012, 11, 28, 0, 0]).format("A"), "ночи", "night");
+        test.equal(moment([2012, 11, 28, 3, 59]).format("A"), "ночи", "night");
+        test.equal(moment([2012, 11, 28, 4, 0]).format("A"), "утра", "morning");
+        test.equal(moment([2012, 11, 28, 11, 59]).format("A"), "утра", "morning");
+        test.equal(moment([2012, 11, 28, 12, 0]).format("A"), "дня", "afternoon");
+        test.equal(moment([2012, 11, 28, 16, 59]).format("A"), "дня", "afternoon");
+        test.equal(moment([2012, 11, 28, 17, 0]).format("A"), "вечера", "evening");
+        test.equal(moment([2012, 11, 28, 23, 59]).format("A"), "вечера", "evening");
+
+        test.done();
+    },
+
     "format ordinal" : function (test) {
         test.expect(31);
 
index 023e62bb50ae102ffc18109d96d0ddb658a13528..a99b9415254367d500ae367f373470d05c0b5106 100644 (file)
@@ -40,7 +40,7 @@ exports["lang:uk"] = {
         test.expect(18);
         var a = [
                 ['dddd, Do MMMM YYYY, HH:mm:ss',       'неділя, 14-го лютого 2010, 15:25:50'],
-                ['ddd, hA',                            'нед, 3PM'],
+                ['ddd, h A',                           'нед, 3 дня'],
                 ['M Mo MM MMMM MMM',                   '2 2-й 02 лютий лют'],
                 ['YYYY YY',                            '2010 10'],
                 ['D Do DD',                            '14 14-го 14'],
@@ -51,7 +51,7 @@ exports["lang:uk"] = {
                 ['H HH',                               '15 15'],
                 ['m mm',                               '25 25'],
                 ['s ss',                               '50 50'],
-                ['a A',                                'pm PM'],
+                ['a A',                                'дня дня'],
                 ['DDDo [день року]',                   '45-й день року'],
                 ['L',                                  '14.02.2010'],
                 ['LL',                                 '14 лютого 2010 р.'],
@@ -66,6 +66,21 @@ exports["lang:uk"] = {
         test.done();
     },
 
+    "format meridiem" : function (test) {
+        test.expect(8);
+
+        test.equal(moment([2012, 11, 28, 0, 0]).format("A"), "ночі", "night");
+        test.equal(moment([2012, 11, 28, 3, 59]).format("A"), "ночі", "night");
+        test.equal(moment([2012, 11, 28, 4, 0]).format("A"), "ранку", "morning");
+        test.equal(moment([2012, 11, 28, 11, 59]).format("A"), "ранку", "morning");
+        test.equal(moment([2012, 11, 28, 12, 0]).format("A"), "дня", "afternoon");
+        test.equal(moment([2012, 11, 28, 16, 59]).format("A"), "дня", "afternoon");
+        test.equal(moment([2012, 11, 28, 17, 0]).format("A"), "вечора", "evening");
+        test.equal(moment([2012, 11, 28, 23, 59]).format("A"), "вечора", "evening");
+
+        test.done();
+    },
+
     "format ordinal" : function (test) {
         test.expect(31);
         test.equal(moment([2011, 0, 1]).format('DDDo'), '1-й', '1-й');