{"record":{"id":"c791785f87c94199","repo":"ionic-team/ionic-framework","slug":"no-day-of-week-provided","errorCode":null,"errorMessage":"No day of week provided","messagePattern":"No day of week provided","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"core/src/components/datetime/utils/manipulation.ts","lineNumber":92,"sourceCode":"  /**\n   * If PM and 12pm\n   * just return 12:00\n   * since it is already\n   * in 24 hour format.\n   * Otherwise add 12 hours\n   * to the time.\n   */\n  if (hour === 12) {\n    return 12;\n  }\n\n  return hour + 12;\n};\n\nexport const getStartOfWeek = (refParts: DatetimeParts): DatetimeParts => {\n  const { dayOfWeek } = refParts;\n  if (dayOfWeek === null || dayOfWeek === undefined) {\n    throw new Error('No day of week provided');\n  }\n\n  return subtractDays(refParts, dayOfWeek);\n};\n\nexport const getEndOfWeek = (refParts: DatetimeParts): DatetimeParts => {\n  const { dayOfWeek } = refParts;\n  if (dayOfWeek === null || dayOfWeek === undefined) {\n    throw new Error('No day of week provided');\n  }\n\n  return addDays(refParts, 6 - dayOfWeek);\n};\n\nexport const getNextDay = (refParts: DatetimeParts): DatetimeParts => {\n  return addDays(refParts, 1);\n};\n","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/ionic-team/ionic-framework/blob/625f9c38ad8c5db8a6c12df5c1622a36da90f9e3/core/src/components/datetime/utils/manipulation.ts#L74-L110","documentation":"Thrown by getStartOfWeek() in manipulation.ts when refParts.dayOfWeek is null or undefined. getStartOfWeek computes the Sunday (or firstDay) anchor of the week by subtracting dayOfWeek days, so a missing dayOfWeek makes the math impossible. This is a data-integrity guard, not user input validation.","triggerScenarios":"getStartOfWeek is called with a DatetimeParts object whose dayOfWeek was never populated or was explicitly set to null - e.g. parts built from a year/month-only value, or a manually constructed object missing the field.","commonSituations":"Constructing DatetimeParts by hand from a partial date; date-only or month-year presentations where dayOfWeek is not computed; a parsing bug that drops dayOfWeek when reading an ISO string without a day.","solutions":["Ensure the DatetimeParts passed in have dayOfWeek computed (derive it via new Date(...).getDay() before calling).","Guard the caller: if dayOfWeek is missing, compute the full date parts first instead of calling getStartOfWeek.","Use Ion's own date parsers to build parts so dayOfWeek is populated consistently.","Add a unit test that asserts dayOfWeek is non-null for every parts object you feed week helpers."],"exampleFix":"// before\nconst start = getStartOfWeek({ month: 5, day: 18, year: 2021 }); // dayOfWeek missing\n\n// after\nconst d = new Date(2021, 4, 18);\nconst start = getStartOfWeek({ month: 5, day: 18, year: 2021, dayOfWeek: d.getDay() });","handlingStrategy":"validation","validationCode":"function withDayOfWeek(parts: DatetimeParts): DatetimeParts {\n  if (parts.dayOfWeek == null && parts.day != null && parts.year != null && parts.month != null) {\n    return { ...parts, dayOfWeek: new Date(parts.year, parts.month - 1, parts.day).getDay() };\n  }\n  return parts;\n}\nconst start = getStartOfWeek(withDayOfWeek(parts));","typeGuard":"function hasDayOfWeek(p: DatetimeParts): p is DatetimeParts & { dayOfWeek: number } {\n  return p.dayOfWeek !== null && p.dayOfWeek !== undefined;\n}","tryCatchPattern":null,"preventionTips":["Always populate dayOfWeek when building DatetimeParts for week math.","Derive dayOfWeek via Date.getDay() at the point you build parts.","Unit-test week helpers with complete parts objects."],"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"}