From: Rocky Meza Date: Fri, 18 Nov 2011 19:54:11 +0000 (-0700) Subject: Fixed 12:00 am bug X-Git-Tag: 1.2.0~33^2 X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=refs%2Fpull%2F74%2Fhead;p=thirdparty%2Fmoment.git Fixed 12:00 am bug The string '12:00 am' was being parsed as 12:00 pm. I fixed that and added a test. --- diff --git a/moment.js b/moment.js index 9565ed16b..47aa3f7a7 100644 --- a/moment.js +++ b/moment.js @@ -261,6 +261,10 @@ if (isPm && inArray[3] < 12) { inArray[3] += 12; } + // if is 12 am, change hours to 0 + if (! isPm && inArray[3] === 12) { + inArray[3] = 0; + } return dateFromArray(inArray); } diff --git a/sitesrc/js/unit-tests.js b/sitesrc/js/unit-tests.js index cde923216..2f2c40ebb 100755 --- a/sitesrc/js/unit-tests.js +++ b/sitesrc/js/unit-tests.js @@ -71,6 +71,8 @@ test("string with format", 13, function() { ['DD-MM-YYYY h:m:s', '12-02-1999 2:45:10'], ['DD-MM-YYYY h:m:s a', '12-02-1999 2:45:10 am'], ['DD-MM-YYYY h:m:s a', '12-02-1999 2:45:10 pm'], + ['h:mm a', '12:00 pm'], + ['h:mm a', '12:00 am'], ['YYYY-MM-DDTHH:mm:ss', '2011-11-11T11:11:11'], ['MM-DD-YYYY \\M', '12-02-1999 M'] ],