SeaUrchinBot / closure-library

Automatically exported from code.google.com/p/closure-library
0 stars 0 forks source link

goog.i18n.DateTimeParse.strictParse() allows illegal dates like "Jun 31, 2012" #476

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
---- What steps will reproduce the problem? -------
var dateParser = new 
goog.i18n.DateTimeParse(goog.i18n.DateTimeFormat.Format.MEDIUM_DATE);

if (dateParser.strictParse("Feb 31, 2012") > 0)
  alert("Date is valid);
else
  alert("Date is invalid);

---- What is the expected output? What do you see instead? ----

The date of Feb 31st is invalid (only 28 or 29 days in that month) therefore 
the parser should reject it.

Original issue reported on code.google.com by jzikov...@gmail.com on 11 Jun 2012 at 8:48

GoogleCodeExporter commented 9 years ago
Did some changes to parsing a while ago, without being aware of this bug.
But now it seems fixed. The code below shows "Date is invalid"

  var dateParser = new goog.i18n.DateTimeParse(goog.i18n.DateTimeFormat.Format.MEDIUM_DATE);
  var date = new Date();

  if (dateParser.strictParse("Feb 31, 2012", date) > 0)
    alert("Date is valid");
  else
    alert("Date is invalid");

Original comment by mn...@google.com on 5 Mar 2014 at 7:33