code: function toDate(str) {
    var millis = Date.parse(str);
    if (isNaN(millis)) {
      throw new Error(l10n.lookupFormat('typesDateNan', [ str ]));
    }
    return new Date(millis);
  }
docs: Utility to convert a string to a date, throwing if the date can't be
  parsed rather than having an invalid date