quasarframework/quasar · error · Error
Invalid Jalaali year ${jy}
Error message
Invalid Jalaali year ${jy} What it means
Quasar's Persian (Jalaali) calendar utilities, ported from jalaali-js, only support Jalaali years -61 through 3177 (the range covered by the 33-year cycle 'breaks' table). jalCalLeap() validates its input against that table and throws when the year falls outside it. It is reached indirectly via jalaaliMonthLength(), which calls it for month 12 length checks.
Source
Thrown at ui/src/utils/date/private.persian.js:64
/*
This function determines if the Jalaali (Persian) year is
leap (366-day long) or is the common year (365 days)
@param jy Jalaali calendar year (-61 to 3177)
@returns number of years since the last leap year (0 to 4)
*/
function jalCalLeap(jy) {
const bl = breaks.length
let jp = breaks[0],
jm,
jump,
leap,
n,
i
if (jy < jp || jy >= breaks[bl - 1]) {
throw new Error('Invalid Jalaali year ' + jy)
}
for (i = 1; i < bl; i += 1) {
jm = breaks[i]
jump = jm - jp
if (jy < jm) {
break
}
jp = jm
}
n = jy - jp
if (jump - n < 6) {
n = n - jump + div(jump + 4, 33) * 33
}
leap = mod(mod(n + 1, 33) - 1, 4)
if (leap === -1) {
leap = 4View on GitHub (pinned to 4841521b5f)
Solutions
- Validate the year before calling: throw/handle when jy < -61 || jy > 3177.
- Clamp or normalize out-of-range years to the supported -61..3177 window.
- If you need dates outside this era, use a different calendar library with wider coverage instead of Quasar's Persian utils.
Example fix
// before
const days = jalaaliMonthLength(jy, 12)
// after
if (jy < -61 || jy > 3177) {
throw new RangeError(`Jalaali year ${jy} outside supported range -61..3177`)
}
const days = jalaaliMonthLength(jy, 12) Defensive patterns
Strategy: validation
Validate before calling
function isValidJalaaliYear(jy) {
return typeof jy === 'number' && Number.isInteger(jy) && jy >= -61 && jy <= 3177
}
if (!isValidJalaaliYear(jy)) throw new RangeError(`Unsupported Jalaali year: ${jy}`) Type guard
function isValidJalaaliYear(jy) {
return typeof jy === 'number' && Number.isInteger(jy) && jy >= -61 && jy <= 3177
} Try / catch
let days
try {
days = jalaaliMonthLength(jy, 12)
} catch (err) {
if (/Invalid Jalaali year/.test(err.message)) {
days = 29 // fallback for out-of-range years
} else throw err
} Prevention
- Always bound-check Persian years against -61..3177 before calendar math.
- Sanitize user-entered years (reject NaN, non-integers, absurd values) at the form level.
- Add a unit test covering the range edges (jy = -61, 3177, -62, 3178).
When it happens
Trigger: Calling jalaaliMonthLength(jy, 12) (or any code path reaching jalCalLeap) with jy < -61 or jy >= 3178, e.g. jalaaliMonthLength(3178, 12) or jalaaliMonthLength(-62, 5).
Common situations: Computing Persian dates from user input without bounds checks; generating date pickers across extreme ranges; arithmetic on Jalaali years that overflows the supported era (e.g. adding centuries to year 3177).
Related errors
AI-assisted analysis of quasarframework/quasar@4841521b5f (2026-08-30).
Data as JSON: /api/errors/6278dd3fab650adc.
Report an issue: GitHub.