TheAlgorithms/Python · error · ValueError

Year out of range. There has to be some sort of limit...righ

Error message

Year out of range. There has to be some sort of limit...right?

What it means

Error "Year out of range. There has to be some sort of limit...right?" thrown in TheAlgorithms/Python.

Source

Thrown at maths/zellers_congruence.py:118

        raise ValueError("Date separator must be '-' or '/'")

    # Get day
    d: int = int(date_input[3] + date_input[4])
    # Validate
    if not 0 < d < 32:
        raise ValueError("Date must be between 1 - 31")

    # Get second separator
    sep_2: str = date_input[5]
    # Validate
    if sep_2 not in ["-", "/"]:
        raise ValueError("Date separator must be '-' or '/'")

    # Get year
    y: int = int(date_input[6] + date_input[7] + date_input[8] + date_input[9])
    # Arbitrary year range
    if not 45 < y < 8500:
        raise ValueError(
            "Year out of range. There has to be some sort of limit...right?"
        )

    # Get datetime obj for validation
    dt_ck = datetime.date(int(y), int(m), int(d))

    # Start math
    if m <= 2:
        y = y - 1
        m = m + 12
    # maths var
    c: int = int(str(y)[:2])
    k: int = int(str(y)[2:])
    t: int = int(2.6 * m - 5.39)
    u: int = int(c / 4)
    v: int = int(k / 4)
    x: int = int(d + k)
    z: int = int(t + u + v + x)

View on GitHub (pinned to f5988cc097)

Solutions

  1. Enter a year within the supported range of the algorithm.

When it happens

Trigger: Thrown at maths/zellers_congruence.py:118 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of TheAlgorithms/Python@f5988cc097 (2026-08-14). Data as JSON: /api/errors/1ffbe56b9933e910. Report an issue: GitHub.