{"record":{"id":"d4927dfd70bbcfdf","repo":"microsoft/playwright","slug":"invalid-date-epoch","errorCode":null,"errorMessage":"Invalid date: ${epoch}","messagePattern":"Invalid date: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/playwright-core/src/server/clock.ts","lineNumber":153,"sourceCode":"    );\n  }\n\n  while (i--) {\n    parsed = parseInt(strings[i], 10);\n    if (parsed >= 60)\n      throw new Error(`Invalid time ${str}`);\n    ms += parsed * Math.pow(60, l - i - 1);\n  }\n\n  return ms * 1000;\n}\n\nfunction parseTime(epoch: string | number | undefined): number {\n  if (!epoch)\n    return 0;\n  const parsed = new Date(epoch);\n  if (!isFinite(parsed.getTime()))\n    throw new Error(`Invalid date: ${epoch}`);\n  return typeof epoch === 'number' ? epoch : parsed.getTime();\n}\n","sourceCodeStart":135,"sourceCodeEnd":156,"githubUrl":"https://github.com/microsoft/playwright/blob/c8fc3bf8d31542d59b4d4d9eaab1df93ff541dc6/packages/playwright-core/src/server/clock.ts#L135-L156","documentation":"Thrown by parseTime in clock.ts:153. new Date(epoch).getTime() returned NaN (non-finite), so the epoch value passed to clock.install / setFixedTime / setTime could not be interpreted as a date.","triggerScenarios":"clock.setFixedTime('foo'); clock.setTime('2024-13-40'); clock.setFixedTime(NaN); an out-of-range or unparseable date string.","commonSituations":"User-typed date strings; locale-formatted dates the Date constructor rejects; passing undefined fields through to the clock.","solutions":["Pass a valid epoch number (milliseconds) or a Date-parseable ISO string.","Construct the value via new Date(...).getTime() and confirm isFinite before passing.","Use Date.now() for 'current time' installs."],"exampleFix":"// before\nawait page.clock.setFixedTime('noon');\n// after\nawait page.clock.setFixedTime(new Date('2024-01-01T12:00:00Z').getTime());","handlingStrategy":"validation","validationCode":"// Validate the epoch before installing the clock.\nfunction toEpoch(v: number | string): number {\n  const ms = typeof v === 'number' ? v : new Date(v).getTime();\n  if (!Number.isFinite(ms)) throw new Error(`Invalid date for clock: ${v}`);\n  return ms;\n}\nawait page.clock.setFixedTime(toEpoch(input));","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pass epoch milliseconds or an ISO 8601 string.","Confirm isFinite(new Date(v).getTime()) before calling.","Use Date.now() for 'now' installs."],"tags":["clock","validation","date"],"backgroundTag":null,"analyzedSha":"c8fc3bf8d31542d59b4d4d9eaab1df93ff541dc6","analyzedAt":"2026-08-12T07:26:36.950Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}