ionic-team/ionic-framework · error · Error
No day provided
Error message
No day provided
What it means
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.
Source
Thrown at core/src/components/datetime/utils/manipulation.ts:132
export const getPreviousWeek = (refParts: DatetimeParts): DatetimeParts => {
return subtractDays(refParts, 7);
};
export const getNextWeek = (refParts: DatetimeParts): DatetimeParts => {
return addDays(refParts, 7);
};
/**
* Given datetime parts, subtract
* numDays from the date.
* Returns a new DatetimeParts object
* Currently can only go backward at most 1 month.
*/
export const subtractDays = (refParts: DatetimeParts, numDays: number) => {
const { month, day, year } = refParts;
if (day === null) {
throw new Error('No day provided');
}
const workingParts = {
month,
day,
year,
};
workingParts.day = day - numDays;
/**
* If wrapping to previous month
* update days and decrement month
*/
if (workingParts.day < 1) {
workingParts.month -= 1;
}
View on GitHub (pinned to 625f9c38ad)
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.
Example fix
// before
const prev = subtractDays({ month: 5, day: null, year: 2021 }, 7);
// after
if (parts.day == null) {
// handle month/year-only case without day arithmetic
} else {
const prev = subtractDays(parts, 7);
} Defensive patterns
Strategy: validation
Validate before calling
if (parts.day == null) {
// handle month/year-only case without day arithmetic
} else {
subtractDays(parts, n);
} Type guard
function hasDay(p: DatetimeParts): p is DatetimeParts & { day: number } {
return p.day !== null && p.day !== undefined;
} Prevention
- Only call subtractDays (and getStartOfWeek/getPreviousDay/getPreviousWeek) on full dates.
- Reject 'YYYY-MM' inputs before they reach day arithmetic.
- Branch logic on presentation type.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- No day of week provided
- Invalid hour cycle "${hourCycle}"
- Invalid hour cycle "${hourCycle}"
- Hour value not found from DateTimeFormat
- Invalid hour cycle "${hourCycle}"
AI-assisted analysis of ionic-team/ionic-framework@625f9c38ad (2026-08-12).
Data as JSON: /api/errors/0ab5c8c2d2c2ddb2.
Report an issue: GitHub.