if (m._strict) {
m._isValid = m._isValid &&
m._pf.charsLeftOver === 0 &&
- m._pf.unusedTokens.length === 0;
+ m._pf.unusedTokens.length === 0 &&
+ m._pf.bigHour === undefined;
}
}
return m._isValid;
case 'A' :
config._isPm = config._locale.isPM(input);
break;
- // 24 HOUR
- case 'H' : // fall through to hh
- case 'HH' : // fall through to hh
+ // HOUR
case 'h' : // fall through to hh
case 'hh' :
+ config._pf.bigHour = true;
+ /* falls through */
+ case 'H' : // fall through to HH
+ case 'HH' :
datePartArray[HOUR] = toInt(input);
break;
// MINUTE
config._pf.unusedInput.push(string);
}
+ // clear _12h flag if hour is <= 12
+ if (config._pf.bigHour === true && config._a[HOUR] <= 12) {
+ config._pf.bigHour = undefined;
+ }
// handle am pm
if (config._isPm && config._a[HOUR] < 12) {
config._a[HOUR] += 12;
if (config._isPm === false && config._a[HOUR] === 12) {
config._a[HOUR] = 0;
}
-
dateFromConfig(config);
checkOverflow(config);
}
test.done();
},
+ 'h/hh with hour > 12' : function (test) {
+ test.ok(moment('06/20/2014 11:51 PM', 'MM/DD/YYYY hh:mm A', true).isValid(), '11 for hh');
+ test.ok(moment('06/20/2014 11:51 AM', 'MM/DD/YYYY hh:mm A', true).isValid(), '11 for hh');
+ test.ok(moment('06/20/2014 23:51 PM', 'MM/DD/YYYY hh:mm A').isValid(), 'non-strict validity 23 for hh');
+ test.ok(moment('06/20/2014 23:51 PM', 'MM/DD/YYYY hh:mm A').parsingFlags().bigHour, 'non-strict bigHour 23 for hh');
+ test.ok(!moment('06/20/2014 23:51 PM', 'MM/DD/YYYY hh:mm A', true).isValid(), 'validity 23 for hh');
+ test.ok(moment('06/20/2014 23:51 PM', 'MM/DD/YYYY hh:mm A', true).parsingFlags().bigHour, 'bigHour 23 for hh');
+ test.done();
+ },
+
'array bad date leap year' : function (test) {
test.expect(8);