Skip to content
leap-year-analyzer logo

Leap Year Analyzer Skill

leap-year-analyzer

Analyze leap year calculations, calendar systems, and date validation logic. Use this when the user asks about leap year rules, calendar types (Gregorian, Julian, Hebrew, Chinese), year range validation (1582-9999), mathematical formulas, or needs to understand the core leap year detection algori...

SKILL.md

Full skill instructions

Leap Year Analyzer Skill

This Skill helps analyze and understand the leap year calculation logic used in the IsLeapYear application.

When to Use

  • Understanding leap year calculation rules
  • Comparing calendar systems
  • Validating year ranges
  • Explaining mathematical formulas
  • Debugging leap year logic
  • Adding support for new calendar types

Core Leap Year Logic

Located in src/​utils/​leap-year.ts

Gregorian Calendar

The standard leap year rule used globally since 1582:

(year % 4 === 0 && year % 100 !== 0) || year % 400 === 0

Rules:

  1. Divisible by 4 → Leap year
  2. BUT divisible by 100 → Not a leap year
  3. BUT divisible by 400 → Leap year

Valid Range: 1582-9999 (Gregorian calendar introduction to far future)

Examples:

  • 2024 → Leap (divisible by 4, not by 100)
  • 2000 → Leap (divisible by 400)
  • 1900 → Not leap (divisible by 100, not by 400)
  • 2100 → Not leap (divisible by 100, not by 400)

Julian Calendar

Simpler rule used before Gregorian calendar:

year % 4 === 0

Rule: Any year divisible by 4 is a leap year (no century exception)

Hebrew Calendar

Uses Metonic cycle approximation (19-year cycle with 7 leap years):

[3, 6, 8, 11, 14, 17, 19].includes((year % 19) + 1)

Leap years occur in years: 3, 6, 8, 11, 14, 17, 19 of each 19-year cycle

Chinese Calendar

Also uses Metonic cycle approximation:

[3, 5, 8, 11, 13, 16, 19].includes((year % 19) + 1)

Leap years occur in years: 3, 5, 8, 11, 13, 16, 19 of each 19-year cycle

Calendar Type Enum

type CalendarType = "gregorian" | "julian" | "hebrew" | "chinese";

Why 1582 for Gregorian?

Pope Gregory XIII introduced the Gregorian calendar in October 1582 to correct drift in the Julian calendar. The app validates Gregorian dates starting from this year to maintain historical accuracy.

Common Tasks

1. Validating a Year

if (Number.isNaN(year)) {
  return errorResponse("Invalid year parameter");
}

if (year < 1582 || year > 9999) {
  return errorResponse("Year must be between 1582 and 9999");
}

2. Checking Leap Year

Use the functions from src/​utils/​leap-year.ts:

  • isLeapYear(year: number, calendar?: CalendarType): boolean
  • Import: import { isLeapYear } from "@/​utils/​leap-year"

3. Calculating Leap Years in Range

Iterate through range and count:

const leapYears = [];
for (let y = start; y <= end; y++) {
  if (isLeapYear(y, calendar)) {
    leapYears.push(y);
  }
}

Mathematical Insights

Frequency of Leap Years

  • Gregorian: 97 leap years every 400 years (24.25%)
  • Julian: 1 leap year every 4 years (25%)
  • Hebrew/​Chinese: 7 leap years every 19 years (~36.8%)

Century Years

Only 1 in 4 century years is a leap year in Gregorian:

  • 1600 ✓ Leap
  • 1700 ✗ Not leap
  • 1800 ✗ Not leap
  • 1900 ✗ Not leap
  • 2000 ✓ Leap
  • 2100 ✗ Not leap

Testing Leap Year Logic

# Current year (2025 - not a leap year)
curl http://localhost:3000/​api/​check

# Standard leap year
curl http://localhost:3000/​api/​check/​2024

# Century leap year
curl http://localhost:3000/​api/​check/​2000

# Century non-leap year
curl http://localhost:3000/​api/​check/​1900

# Julian vs Gregorian comparison
curl http://localhost:3000/​api/​calendar/​julian/​check/​1900
curl http://localhost:3000/​api/​calendar/​gregorian/​check/​1900

# Batch test edge cases
curl -X POST http://localhost:3000/​api/​check/​batch \
  -H "Content-Type: application/​json" \
  -d '{"years": [1900, 2000, 2024, 2100, 2400]}'

Important Notes

  • Always validate year range for Gregorian calendar (1582-9999)
  • Julian calendar doesn't have the 100/​400 exceptions
  • Hebrew and Chinese calendars use approximations (actual calendars are more complex)
  • The core logic maintains the satirical tone but uses mathematically correct algorithms
  • Functions are exported from src/​utils/​leap-year.ts and used across API routes

More skills from majiayu000

xiaohongshu logo
majiayu000/claude-arsenal

xiaohongshu

xiaohongshu

286 148
View
agent-task-conductor logo
majiayu000/claude-skill-registry

agent-task-conductor

Conduct multi-agent task orchestration and workflow coordination.

663 1
View
conductor-setup logo
majiayu000/claude-skill-registry

conductor-setup

Initialize project with Conductor artifacts (product definition,

663 1
View
animation-designer logo
majiayu000/claude-skill-registry

animation-designer

Expert in web animations, transitions, and motion design using Framer Motion and CSS

663 1
View
diagramming logo
majiayu000/claude-skill-registry

diagramming

Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...

663 1
View
h3-pg logo
majiayu000/claude-skill-registry-data

h3-pg

PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.

23 1
View
conductor-development logo
majiayu000/claude-skill-registry

conductor-development

Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...

663 1
View
conductor-status logo
majiayu000/claude-skill-registry

conductor-status

Display project status, active tracks, and next actions

663 1
View
dockerization logo
majiayu000/claude-skill-registry

dockerization

Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.

663 1
View

Popular AI tools

Kaiber logo
Video

Kaiber

Generate, edit, and beat-sync AI video with leading models in one workspace.

Paid
View
Vimcal logo
Productivity

Vimcal

The world's fastest calendar for remote work

Free
View

Transform Your Design with AI Designer by ImgCreator.ai

Freemium
View
Akool AI logo
Content & writing

Akool AI

Revolutionizing Video Production with AI-Powered Creativity

Paid
View

Extend an image past the frame and let AI fill the new aspect ratio.

Freemium
View
StarByFace logo
Security

StarByFace

Discover your celebrity doppelgänger with StarByFace!

Free
View
C

ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.

Freemium
View
Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View