angular/components · error · 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
LuxonDateAdapter.setTime also validates minutes in dev mode: they must be within 0–59. Values outside this range would cause unintended rollover into the next hour or an invalid DateTime, so the adapter throws instead.
Source
Thrown at src/material-luxon-adapter/adapter/luxon-date-adapter.ts:282
}
invalid(): LuxonDateTime {
return LuxonDateTime.invalid('Invalid Luxon DateTime object.');
}
override setTime(
target: LuxonDateTime,
hours: number,
minutes: number,
seconds: number,
): LuxonDateTime {
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 this.clone(target).set({
hour: hours,
minute: minutes,
second: seconds,
millisecond: 0,
});
}
override getHours(date: LuxonDateTime): number {
return date.hour;
}View on GitHub (pinned to 0411926e7d)
Solutions
- Validate minutes are 0–59 before calling setTime.
- Use Luxon/adapter arithmetic for durations instead of raw minute math: add via a new DateTime rather than setTime.
- Clamp input: `const m = Math.min(59, Math.max(0, rawMinutes));`.
- Constrain custom time pickers to valid ranges (min=0, max=59) so bad values never reach setTime.
Example fix
// before const later = adapter.setTime(date, 10, 75, 0); // throws in dev mode // after const later = adapter.addCalendarMinutes(adapter.setTime(date, 10, 0, 0), 75);
Defensive patterns
Strategy: validation
Validate before calling
function safeSetTime(adapter: DateAdapter<LuxonDateTime>, date: LuxonDateTime, h: number, m: number, s: number) {
if (!Number.isInteger(m) || m < 0 || m > 59) throw new Error(`minutes must be 0-59, got ${m}`);
return adapter.setTime(date, h, m, s);
} Type guard
function isValidMinute(m: unknown): m is number {
return typeof m === 'number' && Number.isInteger(m) && m >= 0 && m <= 59;
} Try / catch
try {
return adapter.setTime(date, hours, minutes, seconds);
} catch (e) {
if (String(e.message).startsWith('Invalid minutes')) {
const m = Math.min(59, Math.max(0, minutes));
return adapter.setTime(date, hours, m, seconds);
}
throw e;
} Prevention
- Use date arithmetic (addCalendarMinutes / Luxon plus) for durations instead of raw minute values > 59.
- Validate time fields from user input or backend data before setTime.
- Clamp values defensively since the built-in check is dev-mode only.
- Set min/max on custom time-picker inputs to 0–59.
When it happens
Trigger: Calling `adapter.setTime(date, h, minutes, s)` with minutes < 0 or > 59 — typically from free-form user input ('90 minutes'), summing durations, or parsing 'mm' fields from malformed strings.
Common situations: Duration arithmetic (e.g. now + 90 minutes) applied directly to the minutes field instead of using Luxon's plus(); custom time inputs without min/max validation; spreadsheet or backend data with out-of-range minute fields.
Related errors
- Invalid month index "${month}". Month index has to be betwee
- Invalid date "${date}". Date has to be greater than 0.
- Formats array must not be empty.
- Formats array must not be empty.
- Invalid date "${date}". Reason: "${result.invalidReason}".
AI-assisted analysis of angular/components@0411926e7d (2026-08-31).
Data as JSON: /api/errors/631db2e7e05161d0.
Report an issue: GitHub.