]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
Moving isPM check to the language object so it can be overwritten by different languages
authorTim Wood <washwithcare@gmail.com>
Mon, 20 May 2013 15:18:15 +0000 (08:18 -0700)
committerTim Wood <washwithcare@gmail.com>
Mon, 20 May 2013 15:18:15 +0000 (08:18 -0700)
moment.js
test/moment/create.js

index 0bb255cf51581a7da8ab38044e4c65119ac59ba1..3c3099022536d60d52d46494242c2534c9f3e81e 100644 (file)
--- a/moment.js
+++ b/moment.js
             return output;
         },
 
+        isPM : function (input) {
+            return ((input + '').toLowerCase()[0] === 'p');
+        },
+
         meridiem : function (hours, minutes, isLower) {
             if (hours > 11) {
                 return isLower ? 'pm' : 'PM';
         // AM / PM
         case 'a' : // fall through to A
         case 'A' :
-            config._isPm = ((input + '').toLowerCase() === 'pm');
+            config._isPm = getLangDefinition(config._l).isPM(input);
             break;
         // 24 HOUR
         case 'H' : // fall through to hh
index c932732f50d0e918ac5abad2d32c4844ef7086fd..03e083242a2242061d71e2f521b64f3ca159fda6 100644 (file)
@@ -123,9 +123,12 @@ exports.create = {
     },
 
     "matching am/pm" : function(test) {
-        test.expect(1);
+        test.expect(4);
 
         test.equal(moment('2012-09-03T03:00PM', 'YYYY-MM-DDThh:mmA').format('YYYY-MM-DDThh:mmA'), '2012-09-03T03:00PM', 'am/pm should parse correctly even if the input string contains other letters');
+        test.equal(moment('2012-09-03T03:00P.M.', 'YYYY-MM-DDThh:mmA').format('YYYY-MM-DDThh:mmA'), '2012-09-03T03:00PM', 'am/pm should parse correctly even if the input string contains other letters');
+        test.equal(moment('2012-09-03T03:00pm', 'YYYY-MM-DDThh:mmA').format('YYYY-MM-DDThh:mmA'), '2012-09-03T03:00PM', 'am/pm should parse correctly even if the input string contains other letters');
+        test.equal(moment('2012-09-03T03:00p.m.', 'YYYY-MM-DDThh:mmA').format('YYYY-MM-DDThh:mmA'), '2012-09-03T03:00PM', 'am/pm should parse correctly even if the input string contains other letters');
 
         test.done();
     },