{"record":{"id":"34676940203fd1d1","repo":"angular/components","slug":"invalid-seconds-seconds-seconds-value-must-b-346769","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-moment-adapter/adapter/moment-date-adapter.ts","lineNumber":256,"sourceCode":"    return this.clone(date).isValid();\n  }\n\n  invalid(): Moment {\n    return moment.invalid();\n  }\n\n  override setTime(target: Moment, hours: number, minutes: number, seconds: number): Moment {\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({hours, minutes, seconds, milliseconds: 0});\n  }\n\n  override getHours(date: Moment): number {\n    return date.hours();\n  }\n\n  override getMinutes(date: Moment): number {\n    return date.minutes();\n  }\n\n  override getSeconds(date: Moment): number {\n    return date.seconds();\n  }\n","sourceCodeStart":238,"sourceCodeEnd":274,"githubUrl":"https://github.com/angular/components/blob/0411926e7d8ae06b32236ec1048a888cfad5abf2/src/material-moment-adapter/adapter/moment-date-adapter.ts#L238-L274","documentation":"MomentDateAdapter.setTime validates the seconds argument (0-59) before calling Moment's set(). Out-of-range seconds would roll into minutes or produce garbage, so the adapter throws this explicit ngDevMode error, matching the hours and minutes guards in the same method.","triggerScenarios":"Calling setTime(target, hours, minutes, seconds) with seconds < 0 or > 59 — e.g. passing milliseconds as seconds, epoch-derived values not taken mod 60, or negative results from offset math.","commonSituations":"Timestamp math leaks (timestamp % 1000 passed as seconds), leap-second or offset-subtraction producing -1, unvalidated network data, argument transposition.","solutions":["Clamp seconds to 0-59 before the call.","Convert milliseconds: Math.floor(ms / 1000) % 60, or pass ms via a separate set() call.","Check the upstream computation for unit confusion.","Confirm argument order (target, hours, minutes, seconds)."],"exampleFix":"// before\nadapter.setTime(date, h, m, msSinceMinute); // ms, not seconds\n// after\nadapter.setTime(date, h, m, Math.floor(msSinceMinute / 1000));","handlingStrategy":"validation","validationCode":"function canSetTime(h: number, m: number, s: number): boolean {\n  return [h, m, s].every(Number.isInteger) && h >= 0 && h <= 23 && m >= 0 && m <= 59 && s >= 0 && s <= 59;\n}","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":["Convert ms to seconds explicitly (floor(ms/1000) % 60) before setTime","Clamp seconds at input boundaries","Avoid passing raw timestamp remainders as components","Assert component ranges in tests around time math"],"tags":["date-adapter","moment","validation","time"],"backgroundTag":"invalid-time-component","analyzedSha":"0411926e7d8ae06b32236ec1048a888cfad5abf2","analyzedAt":"2026-08-31T11:58:23.400Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}