Page MenuHomePhabricator

fancy date picker breaks browser if year < 1970
Closed, ResolvedPublic

Description

Chrome Version 60.0.3112.90 (Official Build) (64-bit) on Windows:

  • Find a fancy date picker, like in Calendar > New Event.
  • Set year to 1917
  • click the button

browser hangs forever.

From step-debugging, it looks like this is what's happening there:

behavior-fancy-datepicker.js
function getValidDate() {
  var written_date = new Date(value_y, value_m-1, value_d);  // value_y is "1917" - string.

  if (isNaN(written_date.getTime())) {
    return new Date();
  } else {
    //year 01 should be 2001, not 1901
    if (written_date.getYear() < 70) {                       // written_date.getYear() is 17
      value_y += 2000;                                       // value_y is now "19172000"
      written_date = new Date(value_y, value_m-1, value_d);  // written_date is something called "undefined date"?!
    }

    // adjust for a date like February 31
    var adjust = 1;
    while (written_date.getMonth() !== value_m-1) {          // whatever "undefined date" is, this condition is true.
      written_date = new Date(value_y, value_m-1, value_d-adjust);
      adjust++;
    }
}