Functional Weave
Code in Rust

dates.is-leap-year@1.0.0

impl/python.py

612 bytes · the Python implementation · view raw

Imports name this capability’s declared dependencies, which fune builds next to it in your project; each one links to its page.

from .dates_add_days import is_leap_year as _kernel_is_leap_year  ← from dates.add-days ^1.0.0 · built alongside by fune


def is_leap_year(year: int) -> bool:
    """Whether a year is a Gregorian leap year.

    The rule lives in dates.add-days; this adds the range check so a year of 0
    or 10000 fails loudly rather than answering for a year no ISO date can name.
    """
    if isinstance(year, bool) or not isinstance(year, int):
        raise TypeError("year must be an integer, received %r" % (year,))
    if year < 1 or year > 9999:
        raise ValueError("year %s is outside the supported range 1 to 9999" % (year,))
    return _kernel_is_leap_year(year)