{"record":{"id":"631db2e7e05161d0","repo":"angular/components","slug":"invalid-minutes-minutes-minutes-value-must-b-631db2","errorCode":null,"errorMessage":"Invalid minutes \"${minutes}\". Minutes value must be between 0 and 59.","messagePattern":"Invalid minutes \"(.+?)\"\\. Minutes value must be between 0 and 59\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/material-luxon-adapter/adapter/luxon-date-adapter.ts","lineNumber":282,"sourceCode":"  }\n\n  invalid(): LuxonDateTime {\n    return LuxonDateTime.invalid('Invalid Luxon DateTime object.');\n  }\n\n  override setTime(\n    target: LuxonDateTime,\n    hours: number,\n    minutes: number,\n    seconds: number,\n  ): LuxonDateTime {\n    if (typeof ngDevMode === 'undefined' || ngDevMode) {\n      if (hours < 0 || hours > 23) {\n        throw Error(`Invalid hours \"${hours}\". Hours value must be between 0 and 23.`);\n      }\n\n      if (minutes < 0 || minutes > 59) {\n        throw Error(`Invalid minutes \"${minutes}\". Minutes value must be between 0 and 59.`);\n      }\n\n      if (seconds < 0 || seconds > 59) {\n        throw Error(`Invalid seconds \"${seconds}\". Seconds value must be between 0 and 59.`);\n      }\n    }\n\n    return this.clone(target).set({\n      hour: hours,\n      minute: minutes,\n      second: seconds,\n      millisecond: 0,\n    });\n  }\n\n  override getHours(date: LuxonDateTime): number {\n    return date.hour;\n  }","sourceCodeStart":264,"sourceCodeEnd":300,"githubUrl":"https://github.com/angular/components/blob/0411926e7d8ae06b32236ec1048a888cfad5abf2/src/material-luxon-adapter/adapter/luxon-date-adapter.ts#L264-L300","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nconst later = adapter.setTime(date, 10, 75, 0); // throws in dev mode\n\n// after\nconst later = adapter.addCalendarMinutes(adapter.setTime(date, 10, 0, 0), 75);","handlingStrategy":"validation","validationCode":"function safeSetTime(adapter: DateAdapter<LuxonDateTime>, date: LuxonDateTime, h: number, m: number, s: number) {\n  if (!Number.isInteger(m) || m < 0 || m > 59) throw new Error(`minutes must be 0-59, got ${m}`);\n  return adapter.setTime(date, h, m, s);\n}","typeGuard":"function isValidMinute(m: unknown): m is number {\n  return typeof m === 'number' && Number.isInteger(m) && m >= 0 && m <= 59;\n}","tryCatchPattern":"try {\n  return adapter.setTime(date, hours, minutes, seconds);\n} catch (e) {\n  if (String(e.message).startsWith('Invalid minutes')) {\n    const m = Math.min(59, Math.max(0, minutes));\n    return adapter.setTime(date, hours, m, seconds);\n  }\n  throw e;\n}","preventionTips":["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."],"tags":["angular-material","luxon","time-validation","invalid-argument"],"backgroundTag":"invalid-time-value","analyzedSha":"0411926e7d8ae06b32236ec1048a888cfad5abf2","analyzedAt":"2026-08-31T11:58:23.400Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}