angular/components · error
Invalid minutes "${minutes}". Minutes value must be between
Error message
Invalid minutes "${minutes}". Minutes value must be between 0 and 59. What it means
DateFnsAdapter.setTime validates the minutes argument (must be 0–59) and throws in dev mode when out of range, preventing silent rollover into the next hour by the native Date.
Source
Thrown at src/material-date-fns-adapter/adapter/date-fns-adapter.ts:227
return isDate(obj);
}
isValid(date: Date): boolean {
return isValid(date);
}
invalid(): Date {
return new Date(NaN);
}
override setTime(target: Date, hours: number, minutes: number, seconds: number): Date {
if (typeof ngDevMode === 'undefined' || ngDevMode) {
if (hours < 0 || hours > 23) {
throw Error(`Invalid hours "${hours}". Hours value must be between 0 and 23.`);
}
if (minutes < 0 || minutes > 59) {
throw Error(`Invalid minutes "${minutes}". Minutes value must be between 0 and 59.`);
}
if (seconds < 0 || seconds > 59) {
throw Error(`Invalid seconds "${seconds}". Seconds value must be between 0 and 59.`);
}
}
return set(this.clone(target), {hours, minutes, seconds, milliseconds: 0});
}
override getHours(date: Date): number {
return getHours(date);
}
override getMinutes(date: Date): number {
return getMinutes(date);
}
View on GitHub (pinned to 0411926e7d)
Solutions
- Use addCalendarMinutes for arithmetic exceeding 59 rather than setTime.
- Validate/parse time strings and reject out-of-range components before calling.
- Clamp or wrap minute values ((minute % 60) with carry into hours) when appropriate.
Example fix
// before this.adapter.setTime(target, 10, 60, 0); // throws // after this.adapter.setTime(this.adapter.addCalendarMinutes(target, 60), 0, 0, 0); // or wrap to 11:00
Defensive patterns
Strategy: validation
Validate before calling
if (!Number.isInteger(minutes) || minutes < 0 || minutes > 59) {
throw new RangeError(`minutes must be 0-59, got ${minutes}`);
}
const d = adapter.setTime(target, hours, minutes, seconds); Type guard
function isValidMinute(m: unknown): m is number {
return typeof m === 'number' && Number.isInteger(m) && m >= 0 && m <= 59;
} Try / catch
try {
return this.adapter.setTime(t, h, m, s);
} catch (e) {
if ((e as Error).message.startsWith('Invalid minutes')) {
return this.adapter.setTime(t, h, Math.min(Math.max(m, 0), 59), s);
}
throw e;
} Prevention
- Use addCalendarMinutes for arithmetic that can exceed 59
- Parse 'HH:mm' strings with range validation (0-23, 0-59)
- Clamp free-text minute inputs before use
- Keep duration math and clock-time setting in separate helpers
When it happens
Trigger: Calling setTime(target, hours, minutes, seconds) with minutes < 0 or minutes > 59 — e.g. minute arithmetic like minute + 15 = 60, or unvalidated/free-text time input like '90'.
Common situations: Duration math (minutes sum > 59) passed straight to setTime; parsing 'HH:mm' strings without range checks; typo'd constants (e.g. 60 instead of 59 as a max).
Related errors
- Invalid hours "${hours}". Hours value must be between 0 and
- Invalid seconds "${seconds}". Seconds value must be between
- Invalid month index "${month}". Month index has to be betwee
- Invalid date "${date}". Date has to be greater than 0.
- Invalid date "${date}" for month with index "${month}".
AI-assisted analysis of angular/components@0411926e7d (2026-08-31).
Data as JSON: /api/errors/56a41233831ad6bd.
Report an issue: GitHub.