{"record":{"id":"7d7b85f271e3f31e","repo":"angular/components","slug":"invalid-seconds-seconds-seconds-value-must-b-7d7b85","errorCode":null,"errorMessage":"Invalid seconds \"${seconds}\". Seconds value must be between 0 and 59.","messagePattern":"Invalid seconds \"(.+?)\"\\. Seconds 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":286,"sourceCode":"  }\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  }\n\n  override getMinutes(date: LuxonDateTime): number {\n    return date.minute;\n  }","sourceCodeStart":268,"sourceCodeEnd":304,"githubUrl":"https://github.com/angular/components/blob/0411926e7d8ae06b32236ec1048a888cfad5abf2/src/material-luxon-adapter/adapter/luxon-date-adapter.ts#L268-L304","documentation":"The Material Luxon date adapter's setTime validates the seconds argument before applying it to the target DateTime. Seconds must be a whole number between 0 and 59; anything outside that range would produce an invalid Luxon DateTime, so the adapter throws a descriptive error in ngDevMode instead. This mirrors the same guards applied to hours and minutes.","triggerScenarios":"Calling setTime(target, hours, minutes, seconds) on a LuxonDateAdapter with seconds < 0 or seconds > 59, e.g. computing seconds from a buggy formula, parsing user input without clamping, or accidentally passing milliseconds (e.g. 250) as seconds.","commonSituations":"Passing a Date.getSeconds()-style value that is actually milliseconds, off-by-one or arithmetic mistakes when deriving seconds from a timestamp, unvalidated form fields, or locale/timezone code that subtracts time offsets producing negative values.","solutions":["Clamp or validate seconds to 0-59 before calling setTime (e.g. Math.min(59, Math.max(0, seconds))).","If you have milliseconds, convert first: Math.floor(ms / 1000) % 60.","Verify argument order — seconds is the fourth parameter of setTime; a transposed argument list is common.","Fix the upstream calculation producing the out-of-range value (unit test the arithmetic)."],"exampleFix":"// before\nadapter.setTime(date, 10, 30, inputSeconds); // inputSeconds could be 75\n// after\nconst safeSeconds = Math.min(59, Math.max(0, Math.floor(inputSeconds)));\nadapter.setTime(date, 10, 30, safeSeconds);","handlingStrategy":"validation","validationCode":"function canSetTime(seconds: number): boolean {\n  return Number.isInteger(seconds) && seconds >= 0 && seconds <= 59;\n}\nif (!canSetTime(seconds)) seconds = Math.min(59, Math.max(0, Math.floor(seconds)));","typeGuard":"function isValidSeconds(s: unknown): s is number {\n  return typeof s === 'number' && Number.isInteger(s) && s >= 0 && s <= 59;\n}","tryCatchPattern":"try {\n  adapter.setTime(date, h, m, s);\n} catch (e) {\n  if (e instanceof Error && e.message.includes('Invalid seconds')) {\n    adapter.setTime(date, h, m, Math.min(59, Math.max(0, Math.floor(s))));\n  } else throw e;\n}","preventionTips":["Clamp/normalize all time components at input boundaries before adapter calls","Use Math.floor(ms/1000) % 60 when converting from milliseconds","Unit-test time arithmetic helpers for range compliance","Keep the (target, hours, minutes, seconds) argument order fixed via a named-parameter wrapper"],"tags":["date-adapter","luxon","validation","arguments"],"backgroundTag":"invalid-time-component","analyzedSha":"0411926e7d8ae06b32236ec1048a888cfad5abf2","analyzedAt":"2026-08-31T11:58:23.400Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}