# Korean lunar date conversion

This project uses the pinned `kor-lunar@1.7.0` package for Korean lunar-calendar data and conversion. The package describes its conversion data as based on public Korean Astronomy and Space Science Institute (KASI) data, current to 2025-05-20. See the [KASI 음양력 정보 API](https://www.data.go.kr/data/15012679/openapi.do) and the [`kor-lunar` project](https://github.com/kahyou22/kor-lunar-js).

## Supported dates

The HeyU adapter accepts lunar years **1900 through 2050**, inclusive. The library itself supports a wider overall table: lunar 1890-01-01 through **2050-11-18**, and solar 1890-01-21 through 2050-12-31. Since HeyU's requested lower input bound is 1900, the effective accepted lunar inputs are 1900-01-01 through **2050-11-18** (with the actual month/day validity rules applied). The final lunar date converts to solar 2050-12-31. 2050 lunar month options stop at month 11, with that final month limited to 18 valid days; 2050 month 12 and 2050-11-19 onward are unsupported.

The dependency's low-level `toSolar()` does not verify that a lunar month/day actually exists. The adapter therefore validates dates with `LunarCalendar.isValid()` first. This rejects nonexistent leap months, dates beyond a month's length, and inputs beyond the library's final date.

## Module API (`src/korean-lunar.js`)

- `getKoreanLunarMonthOptions(year)` returns an array of `{ month, isLeap, days }` records for valid months. Unsupported years return an empty array. Numeric year strings are accepted.
- `getKoreanLunarMonthDays(year, month, isLeap = false)` returns the valid number of days in that regular or leap month, or `0` if the month is absent or unsupported. At the 2050 boundary the final month reports 18 days.
- `koreanLunarToSolar(year, month, day, isLeapMonth = false)` returns `{ year, month, day }` for a valid lunar date. It throws `RangeError` for unsupported years/dates, nonexistent leap months, or impossible month-days.
- `KOREAN_LUNAR_MIN_YEAR` and `KOREAN_LUNAR_MAX_YEAR` export the adapter's inclusive year bounds (1900 and 2050).

## Reference checks

The module tests include KASI reference conversions for lunar 1997-01-01 → solar 1997-02-08 and lunar 2006-01-01 → solar 2006-01-29, as well as a valid 2023 leap-month date, nonexistent leap-month and invalid-day cases, and the exact 2050 endpoint.

## Third-party license

`kor-lunar@1.7.0` is distributed under the MIT License. Its copyright and permission notice are reproduced here to satisfy the license condition.

```text
MIT License

Copyright (c) 2025 Munju Jeong

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
```
