{"record":{"id":"8a06027ccbf8461a","repo":"quasarframework/quasar","slug":"date-issamedate-unknown-unit-unit","errorCode":null,"errorMessage":"date isSameDate unknown unit ${unit}","messagePattern":"date isSameDate unknown unit (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"ui/src/utils/date/date.js","lineNumber":838,"sourceCode":"      if (t.getDate() !== d.getDate()) {\n        return false\n      }\n    }\n    case 'month': // oxlint-disable-line no-fallthrough\n    case 'months': {\n      if (t.getMonth() !== d.getMonth()) {\n        return false\n      }\n    }\n    case 'year': // oxlint-disable-line no-fallthrough\n    case 'years': {\n      if (t.getFullYear() !== d.getFullYear()) {\n        return false\n      }\n      break\n    }\n    default: {\n      throw new Error(`date isSameDate unknown unit ${unit}`)\n    }\n  }\n\n  return true\n}\n\nexport function daysInMonth(date, utc) {\n  const prefix = utc ? 'UTC' : '',\n    t = new Date(date)\n\n  t[`set${prefix}Date`](1)\n  t[`set${prefix}Month`](t[`get${prefix}Month`]() + 1)\n  t[`set${prefix}Date`](0)\n\n  return t[`get${prefix}Date`]()\n}\n\nfunction getOrdinal(n) {","sourceCodeStart":820,"sourceCodeEnd":856,"githubUrl":"https://github.com/quasarframework/quasar/blob/4841521b5f635a971eb9e2710e5542efd194691b/ui/src/utils/date/date.js#L820-L856","documentation":"Quasar's internal date utils (isSameDate and friends) accept a unit string such as 'year', 'month', 'day'. When the unit does not match any known case, the switch's default branch throws this Error. This indicates a bug or an unsupported unit passed into the date comparison utility, not a user-input validation error.","triggerScenarios":"Calling internal date comparison helpers (via utils.isSameDate-style code paths) with a unit like 'week', 'hour', or a misspelled/uppercased value ('Year', 'days') that has no matching switch case.","commonSituations":"Passing units copied from other date libraries (date-fns/moment support many more units than Quasar's util); capitalization mismatches; dynamic units derived from user config; calling private helpers not part of the public API surface.","solutions":["Use only supported units: 'year', 'month', 'day' (check the switch cases in ui/src/utils/date/date.js).","Lowercase/normalize the unit before passing: unit.toLowerCase().","Implement unsupported units yourself (e.g. compare weeks by comparing start-of-week days).","Report/verify against the Quasar version — newer versions may add units."],"exampleFix":"// before\nisSameDate(d1, d2, 'week') // unknown unit, throws\n// after\nisSameDate(d1, d2, 'day') // use a supported unit","handlingStrategy":"validation","validationCode":"const SUPPORTED_UNITS = ['year', 'month', 'day']\nif (!SUPPORTED_UNITS.includes(unit)) {\n  throw new Error(`Unsupported date unit: ${unit}`)\n}","typeGuard":"const isSupportedUnit = (u) => u === 'year' || u === 'month' || u === 'day'","tryCatchPattern":"let same\ntry {\n  same = compareDates(d1, d2, unit)\n} catch (err) {\n  if (err instanceof Error && /unknown unit/.test(err.message)) {\n    console.warn(`Unit '${unit}' not supported, falling back to 'day'`)\n    same = compareDates(d1, d2, 'day')\n  } else throw err\n}","preventionTips":["Only use units the Quasar date util supports; do not assume date-fns/moment unit names.","Normalize units to lowercase before passing.","Map third-party units to supported ones (e.g. 'week' -> day-level logic).","Pin the Quasar version and re-check supported units after upgrades."],"tags":["date","unsupported-unit","internal-api","quasar"],"backgroundTag":"unsupported-enum-value","analyzedSha":"4841521b5f635a971eb9e2710e5542efd194691b","analyzedAt":"2026-08-30T01:13:14.944Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}