{"record":{"id":"f3e811b02bc025f6","repo":"angular/components","slug":"invalid-minutes-minutes-minutes-value-must-b-f3e811","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/core/datetime/native-date-adapter.ts","lineNumber":251,"sourceCode":"    return obj instanceof Date;\n  }\n\n  isValid(date: Date) {\n    return !isNaN(date.getTime());\n  }\n\n  invalid(): Date {\n    return new Date(NaN);\n  }\n\n  override setTime(target: Date, hours: number, minutes: number, seconds: number): Date {\n    if (typeof ngDevMode === 'undefined' || ngDevMode) {\n      if (!inRange(hours, 0, 23)) {\n        throw Error(`Invalid hours \"${hours}\". Hours value must be between 0 and 23.`);\n      }\n\n      if (!inRange(minutes, 0, 59)) {\n        throw Error(`Invalid minutes \"${minutes}\". Minutes value must be between 0 and 59.`);\n      }\n\n      if (!inRange(seconds, 0, 59)) {\n        throw Error(`Invalid seconds \"${seconds}\". Seconds value must be between 0 and 59.`);\n      }\n    }\n\n    const clone = this.clone(target);\n    clone.setHours(hours, minutes, seconds, 0);\n    return clone;\n  }\n\n  override getHours(date: Date): number {\n    return date.getHours();\n  }\n\n  override getMinutes(date: Date): number {\n    return date.getMinutes();","sourceCodeStart":233,"sourceCodeEnd":269,"githubUrl":"https://github.com/angular/components/blob/0411926e7d8ae06b32236ec1048a888cfad5abf2/src/material/core/datetime/native-date-adapter.ts#L233-L269","documentation":"setTime validates minutes to the 0-59 range in dev mode; out-of-range minutes would silently roll into hours (60 minutes -> +1 hour) via Date overflow. The adapter throws instead to keep the resulting Date faithful to the requested components.","triggerScenarios":"Calling adapter.setTime(target, h, minutes, s) with minutes < 0 or > 59, typically from unvalidated parsed time strings (_parseTimeString) or duration addition like minutes = 75.","commonSituations":"Free-text time inputs ('9:75'), summing durations into a minutes field, off-by-one when converting seconds to minutes and seconds.","solutions":["Clamp/validate minutes to 0-59 before calling setTime.","Split excess into hours: setTime(target, h + Math.floor(min/60), min % 60, s).","Use adapter.addCalendarMinutes for duration math instead of raw component setting."],"exampleFix":"// before\nadapter.setTime(target, 9, 75, 0);\n// after\nadapter.addCalendarMinutes(adapter.setTime(target, 9, 0, 0), 75);","handlingStrategy":"validation","validationCode":"if (!Number.isInteger(minutes) || minutes < 0 || minutes > 59) {\n  throw new RangeError(`minutes must be 0-59, got ${minutes}`);\n}\nadapter.setTime(target, hours, minutes, seconds);","typeGuard":"function isValidMinutes(m: unknown): m is number {\n  return typeof m === 'number' && Number.isInteger(m) && m >= 0 && m <= 59;\n}","tryCatchPattern":"try {\n  adapter.setTime(target, h, minutes, s);\n} catch (e) {\n  if (e instanceof Error && e.message.includes('Invalid minutes')) {\n    const carry = Math.floor(minutes / 60);\n    adapter.setTime(target, h + carry, minutes % 60, s);\n  } else { throw e; }\n}","preventionTips":["Validate free-text time inputs with a strict HH:mm regex.","Carry minute overflow into hours instead of passing it raw.","Use adapter.addCalendarMinutes for durations."],"tags":["angular-material","date-adapter","time-validation","minutes"],"backgroundTag":"invalid-time-value","analyzedSha":"0411926e7d8ae06b32236ec1048a888cfad5abf2","analyzedAt":"2026-08-31T11:58:23.400Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}