{"ScriptPreparationCode":"var REGEX = /^(\\d{4})-(\\d{2})-(\\d{2})(T(\\d{2}):(\\d{2})(:(\\d{2}))?)?/;\r\n\r\nfunction withRegex(str) {\r\n\tvar match = str.match(REGEX);\r\n\tif (match) {\r\n \treturn new Date(match[1], match[2], match[3], match[5] || 0, match[6] || 0, match[8] || 0);\r\n }\r\n\treturn null;\r\n}\r\n\r\nfunction withSubstr(str) {\r\n var year = parseInt(str.substr(0, 4), 10),\r\n\t\t\tmonth = parseInt(str.substr(5, 2), 10) - 1,\r\n\t\t\tday = parseInt(str.substr(8, 2), 10),\r\n\t\t\thour = 0, minute = 0, second = 0;\r\n\r\n\t\tif (str.indexOf(\u0027T\u0027) \u003E -1) {\r\n\t\t\thour = parseInt(str.substr(11, 2), 10),\r\n\t\t\tminute = parseInt(str.substr(14, 2), 10),\r\n\t\t\tsecond = parseInt(str.substr(17, 2), 10);\r\n\t\t}\r\n\r\n\t\treturn new Date(year, month, day, hour, minute, second);\r\n}","TestCases":[{"Name":"Regex","Code":"for (var i=0; i\u003C100; \u002B\u002Bi) {\r\n\twithRegex(\u00271991-11-26T12:00:00\u0027);\r\n\twithRegex(\u00271991-11-26\u0027);\r\n}","IsDeferred":false},{"Name":"Substr","Code":"for (var i=0; i\u003C100; \u002B\u002Bi) {\r\n\twithSubstr(\u00271991-11-26T12:00:00\u0027);\r\n\twithSubstr(\u00271991-11-26\u0027);\r\n}","IsDeferred":false}]}