]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
Fix parsing of meridiem in locales that have meridiem
authorIskren Chernev <iskren.chernev@gmail.com>
Sat, 27 Sep 2014 21:56:36 +0000 (14:56 -0700)
committerIskren Chernev <iskren.chernev@gmail.com>
Fri, 26 Dec 2014 10:29:30 +0000 (12:29 +0200)
There were many locales that supported meridiem output, but did not support
parsing (meridiemParse and isPM locale keys). Also some locales can not be
parsed with a simple isPM function, because the variants are not different
around noon.

A new isPM function (with new name -- fixPM) is needed that also takes an hour
and returns whether you should add 12 hours or not.

25 files changed:
locale/af.js
locale/ar-sa.js
locale/ar.js
locale/az.js
locale/be.js
locale/bn.js
locale/bo.js
locale/eo.js
locale/fa.js
locale/hi.js
locale/hu.js
locale/hy-am.js
locale/id.js
locale/ja.js
locale/ko.js
locale/ml.js
locale/mr.js
locale/ms-my.js
locale/ne.js
locale/sq.js
locale/ta.js
locale/th.js
locale/uk.js
locale/zh-cn.js
locale/zh-tw.js

index 2fb7adff2204e57a4772a5257bf027467650fb1c..9c7ad95d85e542f291adba3705a254cf508484e1 100644 (file)
         weekdays : 'Sondag_Maandag_Dinsdag_Woensdag_Donderdag_Vrydag_Saterdag'.split('_'),
         weekdaysShort : 'Son_Maa_Din_Woe_Don_Vry_Sat'.split('_'),
         weekdaysMin : 'So_Ma_Di_Wo_Do_Vr_Sa'.split('_'),
+        meridiemParse: /vm|nm/i,
+        isPM : function (input) {
+            return /^nm$/i.test(input);
+        },
         meridiem : function (hours, minutes, isLower) {
             if (hours < 12) {
                 return isLower ? 'vm' : 'VM';
index ea7e2f6b4bfae1ac9ad28ebfa17cfbb105cc3045..731f97be344ce5b623f88f37ad293691f71b0ae2 100644 (file)
             LLL : 'D MMMM YYYY LT',
             LLLL : 'dddd D MMMM YYYY LT'
         },
+        meridiemParse: /ص|م/,
+        isPM : function (input) {
+            return 'م' === input;
+        },
         meridiem : function (hour, minute, isLower) {
             if (hour < 12) {
                 return 'ص';
index d6450087d7c743245b85e2919786b7124c500f0f..828e61876152586f5b3d1a224e81d643c032e308 100644 (file)
             LLL : 'D MMMM YYYY LT',
             LLLL : 'dddd D MMMM YYYY LT'
         },
+        meridiemParse: /ص|م/,
+        isPM : function (input) {
+            return 'م' === input;
+        },
         meridiem : function (hour, minute, isLower) {
             if (hour < 12) {
                 return 'ص';
index d4d143426d604d4b69e9875212c27fcdf18b1a59..7624feea7d354cac11b477fa7b01f53497fa6531 100644 (file)
             y : 'bir il',
             yy : '%d il'
         },
+        meridiemParse: /gecə|səhər|gündüz|axşam/,
+        isPM : function (input) {
+            return /^(gündüz|axşam)$/.test(input);
+        },
         meridiem : function (hour, minute, isLower) {
             if (hour < 4) {
                 return 'gecə';
index 68a6f37cb790f6d781a58596eabe75b3ec16bf0d..d888e21c43194fefc46673c91a26bfd5ddfae668 100644 (file)
             y : 'год',
             yy : relativeTimeWithPlural
         },
-
-
+        meridiemParse: /ночы|раніцы|дня|вечара/,
+        isPM : function (input) {
+            return /^(дня|вечара)$/.test(input);
+        },
         meridiem : function (hour, minute, isLower) {
             if (hour < 4) {
                 return 'ночы';
index e9549d99368cb38bb902ee9db366895f513de271..5b4ab515e88f76883913844402ea8dd43c314aa0 100644 (file)
                 return symbolMap[match];
             });
         },
+        meridiemParse: /রাত|শকাল|দুপুর|বিকেল|রাত/,
+        isPM: function (input) {
+            return /^(দুপুর|বিকেল|রাত)$/.test(input);
+        },
         //Bengali is a vast language its spoken
         //in different forms in various parts of the world.
         //I have just generalized with most common one used
index cece8d133cfb67f25b7fa10133b13351712d4e97..b8e7001aacb13028524d6172d5eb70b30fbecc54 100644 (file)
                 return symbolMap[match];
             });
         },
+        meridiemParse: /མཚན་མོ|ཞོགས་ཀས|ཉིན་གུང|དགོང་དག|མཚན་མོ/,
+        isPM: function (input) {
+            return /^(ཉིན་གུང|དགོང་དག|མཚན་མོ)$/.test(input);
+        },
         meridiem : function (hour, minute, isLower) {
             if (hour < 4) {
                 return 'མཚན་མོ';
index 6a3d097b921505fbabecd65b6b6bce61437c13d2..9e3d045691d7ec424ef113a922cce45b8c42dd30 100644 (file)
             LLL : 'D[-an de] MMMM, YYYY LT',
             LLLL : 'dddd, [la] D[-an de] MMMM, YYYY LT'
         },
+        meridiemParse: /[ap]\.t\.m/i,
+        isPM: function (input) {
+            return input.charAt(0).toLowerCase() === 'p';
+        },
         meridiem : function (hours, minutes, isLower) {
             if (hours > 11) {
                 return isLower ? 'p.t.m.' : 'P.T.M.';
index ad2087a2ee78ce280cfeb37a2b578a2752d49a9c..6d765751cd5fe6b103bd6b5f9082817affb86ba3 100644 (file)
             LLL : 'D MMMM YYYY LT',
             LLLL : 'dddd, D MMMM YYYY LT'
         },
+        meridiemParse: /قبل از ظهر|بعد از ظهر/,
+        isPM: function (input) {
+            return /بعد از ظهر/.test(input);
+        },
         meridiem : function (hour, minute, isLower) {
             if (hour < 12) {
                 return 'قبل از ظهر';
index 73deba5b14593db17f9ec0b27934e0b34570bd96..5e39a81a80acd87b6a5a10c54fcce6931f07bc09 100644 (file)
         },
         // Hindi notation for meridiems are quite fuzzy in practice. While there exists
         // a rigid notion of a 'Pahar' it is not used as rigidly in modern Hindi.
+        meridiemParse: /रात|सुबह|दोपहर|शाम|रात/,
+        isPM: function (input) {
+            // TODO: This is incorrect (look at cutoffs). We need a better isPM interface.
+            return /^(दोपहर|शाम|रात)$/.test(input);
+        },
         meridiem : function (hour, minute, isLower) {
             if (hour < 4) {
                 return 'रात';
index 7eccd1d90339c0d2857f2e3aec920238db716cf5..de8cae9c3fa2cdf207ed69f8559d6f84d32ad986 100644 (file)
             LLL : 'YYYY. MMMM D., LT',
             LLLL : 'YYYY. MMMM D., dddd LT'
         },
+        meridiemParse: /de|du/i,
+        isPM: function (input) {
+            return input.charAt(1).toLowerCase() === 'u';
+        },
         meridiem : function (hours, minutes, isLower) {
             if (hours < 12) {
                 return isLower === true ? 'de' : 'DE';
index 053a845e0628239c66e9f31a1459bf629fac6cde..6e2de8ba6bd52005b8f3df8da52a048e96d4f2e3 100644 (file)
             yy : '%d տարի'
         },
 
+        meridiemParse: /գիշերվա|առավոտվա|ցերեկվա|երեկոյան/,
+        isPM: function (input) {
+            return /^(ցերեկվա|երեկոյան)$/.test(input);
+        },
         meridiem : function (hour) {
             if (hour < 4) {
                 return 'գիշերվա';
index 36a841a61ec8dcad446955e3b1fe2e3c1f249f2b..a4438a3a7ae8ccbc3052e52746f99ffc7654be1a 100644 (file)
             LLL : 'D MMMM YYYY [pukul] LT',
             LLLL : 'dddd, D MMMM YYYY [pukul] LT'
         },
+        meridiemParse: /pagi|siang|sore|malam/,
+        isPM: function (input) {
+            // TODO: This is incorrect (look at cutoffs).
+            return /^(siang|sore|malam)$/.test(input);
+        },
         meridiem : function (hours, minutes, isLower) {
             if (hours < 11) {
                 return 'pagi';
index 3f55bcfd50ccf5bacfe11ec5ece73f9c02b48b2a..1feb202064fe4843f19981936c447bd1be3493f6 100644 (file)
             LLL : 'YYYY年M月D日LT',
             LLLL : 'YYYY年M月D日LT dddd'
         },
+        meridiemParse: /午前|午後/i,
+        isPM : function (input) {
+            return input === '午後';
+        },
         meridiem : function (hour, minute, isLower) {
             if (hour < 12) {
                 return '午前';
index 956345bdef086d81257547fbcce42581e407e079..8f9396f9a5e8e07e0c3364eaf4ab5e68ba351bf0 100644 (file)
@@ -28,9 +28,6 @@
             LLL : 'YYYY년 MMMM D일 LT',
             LLLL : 'YYYY년 MMMM D일 dddd LT'
         },
-        meridiem : function (hour, minute, isUpper) {
-            return hour < 12 ? '오전' : '오후';
-        },
         calendar : {
             sameDay : '오늘 LT',
             nextDay : '내일 LT',
         },
         ordinalParse : /\d{1,2}일/,
         ordinal : '%d일',
-        meridiemParse : /(오전|오후)/,
+        meridiemParse : /오전|오후/,
         isPM : function (token) {
             return token === '오후';
+        },
+        meridiem : function (hour, minute, isUpper) {
+            return hour < 12 ? '오전' : '오후';
         }
     });
 }));
index 38509141c629ff019b366bf335bfd55d0f255ae7..eb877bb1a38474d350af5b71f1193bb14521761d 100644 (file)
             y : 'ഒരു വർഷം',
             yy : '%d വർഷം'
         },
+        meridiemParse: /രാത്രി|രാവിലെ|ഉച്ച കഴിഞ്ഞ്|വൈകുന്നേരം|രാത്രി/i,
+        isPM : function (input) {
+            return /^(ഉച്ച കഴിഞ്ഞ്|വൈകുന്നേരം|രാത്രി)$/.test(input);
+        },
         meridiem : function (hour, minute, isLower) {
             if (hour < 4) {
                 return 'രാത്രി';
index 45c200e8c40111c6b9782dc4741b2c15ec00f44b..28cc5f5b5eb7add6b2cab2122ba96b03e363038f 100644 (file)
                 return symbolMap[match];
             });
         },
+        meridiemParse: /रात्री|सकाळी|दुपारी|सायंकाळी|रात्री/,
+        isPM : function (input) {
+            // TODO: This is wrong.
+            return /^(दुपारी|सायंकाळी|रात्री)$/.test(input);
+        },
         meridiem: function (hour, minute, isLower)
         {
             if (hour < 4) {
index 09ec280b7993454c401ac23188ff757cb37a8e80..ab60c3f621d1927dc6cf9ee1fb2faec25383e91b 100644 (file)
             LLL : 'D MMMM YYYY [pukul] LT',
             LLLL : 'dddd, D MMMM YYYY [pukul] LT'
         },
+        meridiemParse: /pagi|tengahari|petang|malam/,
+        isPM: function (input) {
+            // TODO: This is wrong.
+            return /^(tengahari|petang|malam)$/.test(input);
+        },
         meridiem : function (hours, minutes, isLower) {
             if (hours < 11) {
                 return 'pagi';
index ceb283411d0ec59e16059bef1648f4a900c84f56..87f4fddfcf3a2e7478ef23d0cf38f0dc797b9700 100644 (file)
                 return symbolMap[match];
             });
         },
+        meridiemParse: /राती|बिहान|दिउँसो|बेलुका|साँझ|राती/,
+        isPM : function (input) {
+            // TODO: This is wrong.
+            return /^(दिउँसो|बेलुका|साँझ|राती)$/.test(input);
+        },
         meridiem : function (hour, minute, isLower) {
             if (hour < 3) {
                 return 'राती';
index 415495aa159822a0577755587a78d7d944d02e5e..9a5bc09892a37f651beef4ea641794501b2a083c 100644 (file)
         weekdays : 'E Diel_E Hënë_E Martë_E Mërkurë_E Enjte_E Premte_E Shtunë'.split('_'),
         weekdaysShort : 'Die_Hën_Mar_Mër_Enj_Pre_Sht'.split('_'),
         weekdaysMin : 'D_H_Ma_Më_E_P_Sh'.split('_'),
+        meridiemParse: /PD|MD/,
+        isPM: function (input) {
+            return input.charAt(0) === 'M';
+        },
         meridiem : function (hours, minutes, isLower) {
             return hours < 12 ? 'PD' : 'MD';
         },
index d0356a3ef2ca383bfb5cbe79d72e8f2d9ccfc2be..95179b990648553439e25c88382d0d7f01c3fde8 100644 (file)
@@ -91,6 +91,8 @@
 
         // refer http://ta.wikipedia.org/s/1er1
 
+        // TODO: This is pretty wrong (when hour is equal to 6 10, 14, 18, 20,
+        // 24 (0). Also it doesn't split at 12 (noon).
         meridiem : function (hour, minute, isLower) {
             if (hour >= 6 && hour <= 10) {
                 return ' காலை';
index e3c54229e7c0c4f4abd03227bc666b1ec61cd96c..ec9b840b313f6c0c2671e742018e13c7abbc2130 100644 (file)
             LLL : 'D MMMM YYYY เวลา LT',
             LLLL : 'วันddddที่ D MMMM YYYY เวลา LT'
         },
+        meridiemParse: /ก่อนเที่ยง|หลังเที่ยง/,
+        isPM: function (input) {
+            return input === 'หลังเที่ยง';
+        },
         meridiem : function (hour, minute, isLower) {
             if (hour < 12) {
                 return 'ก่อนเที่ยง';
index 3dce4bcad618269e1d1be7eb28d2282d53878078..84e11ceac246d3c355f57aeda175ceb7d782b499 100644 (file)
 
         // M. E.: those two are virtually unused but a user might want to implement them for his/her website for some reason
 
+        meridiemParse: /ночі|ранку|дня|вечора/,
+        isPM: function (input) {
+            return /^(дня|вечора)$/.test(input);
+        },
         meridiem : function (hour, minute, isLower) {
             if (hour < 4) {
                 return 'ночі';
index b8a0bd2ea8f059e3da8341ef99c9470698915c25..e9421b16e47a5ae8fc62c4535bc8c81f947890a2 100644 (file)
             lll : 'YYYY年MMMD日LT',
             llll : 'YYYY年MMMD日ddddLT'
         },
+        meridiemParse: /凌晨|早上|上午|中午|下午|晚上/,
+        isPM: function (input) {
+            // TODO: This is wrong.
+            return /^(中午|下午|晚上)$/.test(input);
+        },
         meridiem : function (hour, minute, isLower) {
             var hm = hour * 100 + minute;
             if (hm < 600) {
index b3c4439c742cb4d78094f56cacd9a15dfaf63f6a..306dc0e692ac18707d1b684994647253e1a8a91d 100644 (file)
             lll : 'YYYY年MMMD日LT',
             llll : 'YYYY年MMMD日ddddLT'
         },
+        meridiemParse: /早上|上午|中午|下午|晚上/,
+        isPM: function (input) {
+            // TODO: This is wrong.
+            return /^(中午|下午|晚上)$/.test(input);
+        },
         meridiem : function (hour, minute, isLower) {
             var hm = hour * 100 + minute;
             if (hm < 900) {