{"record":{"id":"0ab5c8c2d2c2ddb2","repo":"ionic-team/ionic-framework","slug":"no-day-provided","errorCode":null,"errorMessage":"No day provided","messagePattern":"No day provided","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"core/src/components/datetime/utils/manipulation.ts","lineNumber":132,"sourceCode":"\nexport const getPreviousWeek = (refParts: DatetimeParts): DatetimeParts => {\n  return subtractDays(refParts, 7);\n};\n\nexport const getNextWeek = (refParts: DatetimeParts): DatetimeParts => {\n  return addDays(refParts, 7);\n};\n\n/**\n * Given datetime parts, subtract\n * numDays from the date.\n * Returns a new DatetimeParts object\n * Currently can only go backward at most 1 month.\n */\nexport const subtractDays = (refParts: DatetimeParts, numDays: number) => {\n  const { month, day, year } = refParts;\n  if (day === null) {\n    throw new Error('No day provided');\n  }\n\n  const workingParts = {\n    month,\n    day,\n    year,\n  };\n\n  workingParts.day = day - numDays;\n\n  /**\n   * If wrapping to previous month\n   * update days and decrement month\n   */\n  if (workingParts.day < 1) {\n    workingParts.month -= 1;\n  }\n","sourceCodeStart":114,"sourceCodeEnd":150,"githubUrl":"https://github.com/ionic-team/ionic-framework/blob/625f9c38ad8c5db8a6c12df5c1622a36da90f9e3/core/src/components/datetime/utils/manipulation.ts#L114-L150","documentation":"Thrown by subtractDays() in manipulation.ts when refParts.day is null. subtractDays performs month/year wrap math keyed off the day field, so it cannot proceed without one. The helper is documented as only going back at most one month, and a null day signals an incomplete date payload.","triggerScenarios":"subtractDays is called with parts whose day is null - e.g. a month/year-only DatetimeParts, or parts produced for a 'month' or 'year' presentation that intentionally has no day. Also reached indirectly through getStartOfWeek/getPreviousDay/getPreviousWeek which delegate to subtractDays.","commonSituations":"Switching ion-datetime presentation to month/year and reusing day-based helpers on the resulting parts; manually constructed parts; a parse step that yields day:null for 'YYYY-MM' inputs.","solutions":["Only call subtractDays (and the week/previous helpers that use it) on parts that carry a concrete day.","If you must shift a month/year-only value, branch first: handle the no-day case separately instead of forcing subtractDays.","Validate parts.day !== null at the boundary where you receive parts.","When parsing ISO strings, require a full date (YYYY-MM-DD) before feeding arithmetic helpers."],"exampleFix":"// before\nconst prev = subtractDays({ month: 5, day: null, year: 2021 }, 7);\n\n// after\nif (parts.day == null) {\n  // handle month/year-only case without day arithmetic\n} else {\n  const prev = subtractDays(parts, 7);\n}","handlingStrategy":"validation","validationCode":"if (parts.day == null) {\n  // handle month/year-only case without day arithmetic\n} else {\n  subtractDays(parts, n);\n}","typeGuard":"function hasDay(p: DatetimeParts): p is DatetimeParts & { day: number } {\n  return p.day !== null && p.day !== undefined;\n}","tryCatchPattern":null,"preventionTips":["Only call subtractDays (and getStartOfWeek/getPreviousDay/getPreviousWeek) on full dates.","Reject 'YYYY-MM' inputs before they reach day arithmetic.","Branch logic on presentation type."],"tags":["datetime","date-arithmetic","data-integrity","runtime"],"backgroundTag":null,"analyzedSha":"625f9c38ad8c5db8a6c12df5c1622a36da90f9e3","analyzedAt":"2026-08-12T16:00:25.413Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}