# Leap Year Calculator

> Applies the Gregorian leap-year rule (divisible by 4, except centuries not divisible by 400) to a year and reports the reason, the number of days in the year and in February, and the next and previous leap years.

- Calculator id: `leap-year` · Category: Everyday Life (`everyday`) · Tool name: `classify_leap_year`
- Canonical page: https://tttkmbb.com/everyday/leap-year · This document: https://tttkmbb.com/everyday/leap-year.md · JSON definition: https://tttkmbb.com/everyday/leap-year.json

## Purpose

Applies the Gregorian leap-year rule (divisible by 4, except centuries not divisible by 400) to a year and reports the reason, the number of days in the year and in February, and the next and previous leap years.

**Use when:** You need to know whether a year has 29 February, why, or when the next leap year occurs.

**Do not use when:** You need the weekday or ISO week of a specific date (use day-of-week) or day counts between dates (use date-difference).

## Input

| Parameter | Type | Unit | Required | Description |
| --- | --- | --- | --- | --- |
| `year` | integer |  | required | Year in the (proleptic) Gregorian calendar. (min 1, max 9999) |

## Output

| Field | Type | Unit | Description |
| --- | --- | --- | --- |
| `is_leap` | boolean |  | true when the year has 366 days. |
| `reason` | string |  | Which part of the rule decided the result. |
| `days_in_year` | integer | days | 365 or 366. |
| `days_in_february` | integer | days | 28 or 29. |
| `next_leap_year` | integer |  | First leap year after the given year. |
| `previous_leap_year` | integer |  | Last leap year before the given year (absent for years before 4). |

## Formula

`is_leap = (year mod 4 = 0 and year mod 100 ≠ 0) or year mod 400 = 0`

The Gregorian rule gives a mean year of 365.2425 days. Years before 1582 (or before a country's adoption date) were actually reckoned in the Julian calendar, where every fourth year is leap; this calculator applies the Gregorian rule proleptically.

## Data Sources

- US Naval Observatory – Leap Years — https://aa.usno.navy.mil/faq/leap_years (government, retrieved 2026-09-23)
- Leap year (Wikipedia) — https://en.wikipedia.org/wiki/Leap_year (reference, retrieved 2026-09-23)

Data freshness: `static`. Deterministic formula with fixed constants; results never go stale. Inputs supplied by the caller determine the output.

## API

- `GET https://tttkmbb.com/api/v1/calculate/leap-year?year=…`
- `POST https://tttkmbb.com/api/v1/calculate/leap-year` with JSON body `{"inputs": {…}}`
- Response: unified envelope (`success`, `request`, `result.values`, `result.units`, `sources`, `freshness`, `timestamp`, `next_actions`, `links`); see https://tttkmbb.com/docs/response-format.md
- Schema: https://tttkmbb.com/api/v1/calculators/leap-year · OpenAPI operationId `classify_leap_year` in https://tttkmbb.com/openapi.json
- Authentication: none. Rate limit: fair use, see https://tttkmbb.com/docs/rate-limits.md.

## MCP

- Server: `https://tttkmbb.com/mcp` (Streamable HTTP, JSON-RPC 2.0, no auth)
- Tool:  `run_calculator` with `{"calculator_id": "leap-year", "inputs": {…}}`

## Example

- 2024: inputs `{"year":2024}` → `{"is_leap":true,"reason":"Divisible by 4 and not by 100","days_in_year":366,"days_in_february":29,"next_leap_year":2028,"previous_leap_year":2020}`
- 1900 (century year not divisible by 400): inputs `{"year":1900}` → `{"is_leap":false,"reason":"Divisible by 100 but not by 400","days_in_year":365,"days_in_february":28,"next_leap_year":1904,"previous_leap_year":1896}`

```
GET https://tttkmbb.com/api/v1/calculate/leap-year?year=2024
```

## Limitations

You need the weekday or ISO week of a specific date (use day-of-week) or day counts between dates (use date-difference). The Gregorian rule gives a mean year of 365.2425 days. Years before 1582 (or before a country's adoption date) were actually reckoned in the Julian calendar, where every fourth year is leap; this calculator applies the Gregorian rule proleptically. All values are computed from the formula above; no measurement or live data is involved.

## FAQ

**Was 2000 a leap year?**

Yes: it is divisible by 400. 1900 and 2100 are not leap years because they are divisible by 100 but not by 400.

**Why does the rule skip some century years?**

A solar year is about 365.2422 days; adding a day every 4 years overshoots, so 3 leap days are dropped every 400 years to keep the calendar aligned with the seasons.

## Related

- [Day of the Week Calculator](https://tttkmbb.com/everyday/day-of-week.md) — Weekday, day of year and ISO week of a date.
- [Age Calculator](https://tttkmbb.com/everyday/age.md) — Ages for people born on 29 February.
