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

  1. Only call subtractDays (and the week/previous helpers that use it) on parts that carry a concrete day.
  2. If you must shift a month/year-only value, branch first: handle the no-day case separately instead of forcing subtractDays.
  3. Validate parts.day !== null at the boundary where you receive parts.
  4. 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

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


AI-assisted analysis of ionic-team/ionic-framework@625f9c38ad (2026-08-12). Data as JSON: /api/errors/0ab5c8c2d2c2ddb2. Report an issue: GitHub.