npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

korean-lunar-calendar

v0.4.0

Published

library to convert Korean lunar-calendar to Gregorian

Downloads

46,393

Readme

The Korean and Chinese lunar calendars share the same astronomical basis but can fall on different dates. This library uses the Korean (KARI) standard.

Features

  • Two-way conversion — solar → lunar and lunar → solar, in one small class.
  • Offline — the conversion table is bundled; no network calls, no external services.
  • GapJa (간지) strings — get the sexagenary year/month/day in both Korean (정유년 병오월) and Chinese (丁酉年 丙午月), plus raw cheongan/ganji indices.
  • Leap-month aware — handles intercalation months (윤달) and the 1582 Gregorian reform gap.
  • Input validation — every setter returns a boolean; out-of-range, non-integer, and impossible-leap-month dates are rejected.
  • Typed & dual-format — ships TypeScript types, ESM + CommonJS, plus a minified browser build.
  • Zero runtime dependencies.

Supported range

| Calendar | From | To | | ----------------- | ------------ | ------------ | | Lunar (음력) | 1000-01-01 | 2050-11-18 | | Solar (양력) | 1000-02-13 | 2050-12-31 |

Dates outside this range cause the corresponding setter to return false.

Install

npm install korean-lunar-calendar
// ES Modules
import KoreanLunarCalendar from "korean-lunar-calendar";

// CommonJS
const KoreanLunarCalendar = require("korean-lunar-calendar");
<!-- Browser (CDN) -->
<script src="https://cdn.jsdelivr.net/npm/korean-lunar-calendar/dist/korean-lunar-calendar.min.js"></script>

Usage

Solar → Lunar (양력 → 음력)

const calendar = new KoreanLunarCalendar();

// setSolarDate(year, month, day) → boolean (false if invalid/out of range)
calendar.setSolarDate(2017, 6, 24);

calendar.getLunarCalendar();
// { year: 2017, month: 5, day: 1, intercalation: true }

calendar.getKoreanGapja();
// { year: "정유년", month: "병오월", day: "임오일", intercalation: "윤월" }

calendar.getChineseGapja();
// { year: "丁酉年", month: "丙午月", day: "壬午日", intercalation: "閏月" }

Lunar → Solar (음력 → 양력)

const calendar = new KoreanLunarCalendar();

// setLunarDate(year, month, day, intercalation) → boolean
calendar.setLunarDate(1956, 1, 21, false);

calendar.getSolarCalendar();
// { year: 1956, month: 3, day: 3 }

calendar.getKoreanGapja();
// { year: "병신년", month: "경인월", day: "기사일", intercalation: "" }

Always check the return value of setSolarDate / setLunarDate before reading the result — the getters reflect the last successful set call.

API

new KoreanLunarCalendar() creates a stateful converter. Set a date, then read it back in the other calendar.

| Method | Returns | Description | | ------ | ------- | ----------- | | setSolarDate(year, month, day) | boolean | Set a Gregorian date. Returns false for out-of-range, non-integer, or nonexistent dates. | | setLunarDate(year, month, day, intercalation) | boolean | Set a lunar date. intercalation requests the leap month; returns false if that month has no leap month. | | getSolarCalendar() | CalendarData | The solar date for the last successful set. | | getLunarCalendar() | CalendarData | The lunar date (includes intercalation). | | getKoreanGapja() | GapJaData | Sexagenary cycle in Korean (e.g. 정유년). | | getChineseGapja() | GapJaData | Sexagenary cycle in Chinese characters (e.g. 丁酉年). | | getGapja(isChinese?) | GapJaData | GapJa in Korean by default, Chinese when isChinese is true. | | getGapJaIndex() | { cheongan, ganji } | Raw 0-based cheongan (천간) and ganji (지지) indices for year/month/day. |

Types

interface CalendarData {
  year: number;
  month: number;
  day: number;
  intercalation?: boolean; // present on lunar results
}

interface GapJaData {
  year: string;
  month: string;
  day: string;
  intercalation?: string; // "윤월" / "閏月" when the lunar month is a leap month, else ""
}

getSolarCalendar() and getLunarCalendar() return a copy — mutating the returned object does not affect the converter's internal state.

Validation

Every setter validates its input and returns a boolean, so you can branch on the result:

const calendar = new KoreanLunarCalendar();

// Rejected → return false
calendar.setLunarDate(99, 1, 1, false);   // before supported range
calendar.setSolarDate(2051, 1, 1);        // after supported range
calendar.setSolarDate(2017, 6, 24.5);     // non-integer day
calendar.setSolarDate(1582, 10, 8);       // skipped by the 1582 Gregorian reform
calendar.setLunarDate(2017, 3, 1, true);  // month 3 of 2017 has no leap month

// Accepted → return true
calendar.setLunarDate(1000, 1, 1, false);
calendar.setSolarDate(2050, 12, 31);

Other languages

The same library is available for other ecosystems:

Acknowledgements

Conversion data follows the KARI (Korea Astronomy and Space Science Institute) Korean lunar–solar standard. Many thanks to KARI for publishing the reference tables.

License

MIT © Jinil Lee