kor-lunar 1.5.4 → 1.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
  [![NPM Downloads](https://img.shields.io/npm/dm/kor-lunar.svg)](https://www.npmjs.com/package/kor-lunar)
5
5
  [![License](https://img.shields.io/npm/l/kor-lunar.svg)](https://github.com/kahyou22/kor-lunar-js/blob/main/LICENSE)
6
6
 
7
- 이 라이브러리는 학습용으로 제작되었으며, 한국천문연구원(KASI)의 음력·양력 변환 데이터를 기반으로 한 자바스크립트 라이브러리입니다.
7
+ 한국천문연구원(KASI)의 음력·양력 변환 데이터를 기반으로 한 자바스크립트 라이브러리입니다.
8
8
  네트워크 요청 없이 **오프라인에서도 동작**하고, 별도의 외부 의존성이 없습니다.
9
9
 
10
10
  > **⚠️ 주의:** 데이터는 **2025년 5월 20일 기준**으로 갱신되었습니다.
@@ -13,22 +13,24 @@
13
13
 
14
14
  ## 특징
15
15
 
16
- - **음력 ↔ 양력 변환** - `toLunar`, `toSolar`
17
- - **윤달 처리** - `isLeapMonth` 옵션
18
- - **음력 간지 출력** - 세차(`secha`), 월건(`wolgeon`), 일진(`iljin`)
19
- - 윤달인 경우 `wolgeon`은 빈 문자열로 반환됩니다
20
- - **TypeScript 지원** - 타입 정의 기본 제공
21
- - **Zero Dependencies** - 외부 의존성 없음
16
+ - **음력 ↔ 양력 변환** `toLunar`, `toSolar`
17
+ - **LunarCalendar 클래스** 음력 날짜 연산 객체 (생성, 연산, 비교)
18
+ - **윤달 처리** `isLeapMonth` 옵션
19
+ - **음력 간지 출력** — 세차(`secha`), 월건(`wolgeon`), 일진(`iljin`)
20
+ - **TypeScript 지원** 타입 정의 기본 제공
21
+ - **Zero Dependencies** 외부 의존성 없음
22
22
  - **CJS / ESM / UMD** — 다양한 환경에서 사용 가능
23
23
 
24
- - [예제 사이트](https://kahyou22.github.io/kor-lunar-js/)
24
+ [예제 사이트](https://kahyou22.github.io/kor-lunar-js/)
25
25
 
26
26
  ## 지원 날짜 범위
27
27
 
28
- - **toLunar**: `양력 → 음력` 날짜 범위 1890년 1월 21일 ~ 2050년 12월 31일
29
- - **toSolar**: `음력 양력` 날짜 범위 1890년 1월 1일 ~ 2050년 11월 18일
28
+ | 함수 | 범위 |
29
+ | ----------------------- | ---------------------------------- |
30
+ | `toLunar` (양력 → 음력) | 1890년 1월 21일 ~ 2050년 12월 31일 |
31
+ | `toSolar` (음력 → 양력) | 1890년 1월 1일 ~ 2050년 11월 18일 |
30
32
 
31
- _범위를 벗어난 날짜가 입력될 경우 `RangeError`가 발생하며, 오류 메시지에 입력한 날짜 정보가 포함됩니다._
33
+ _범위를 벗어난 날짜가 입력될 경우 `RangeError`가 발생합니다._
32
34
 
33
35
  ## 설치
34
36
 
@@ -39,10 +41,11 @@ npm install kor-lunar
39
41
  ### 브라우저 CDN
40
42
 
41
43
  ```html
42
- <script src="https://cdn.jsdelivr.net/npm/kor-lunar@1.5/dist/kor-lunar.min.js"></script>
44
+ <script src="https://cdn.jsdelivr.net/npm/kor-lunar@1.6/dist/kor-lunar.min.js"></script>
43
45
  ```
44
46
 
45
- CDN 사용 시 전역 변수 `korLunar`로 접근할 수 있습니다.
47
+ CDN 사용 시 전역 변수 `korLunar`로 접근할 수 있습니다.
48
+ 예기치 않은 변경을 방지하기 위해 **메이저 버전을 고정**하는 것을 권장합니다.
46
49
 
47
50
  ## 사용법
48
51
 
@@ -57,18 +60,15 @@ const korLunar = require("kor-lunar");
57
60
  Named export도 지원합니다:
58
61
 
59
62
  ```js
60
- import { toLunar, toSolar } from "kor-lunar";
63
+ import { toLunar, toSolar, LunarCalendar } from "kor-lunar";
61
64
  ```
62
65
 
63
- ## 예제
64
-
65
- [예제 사이트](https://kahyou22.github.io/kor-lunar-js/)
66
+ ### 양력 → 음력 (`toLunar`)
66
67
 
67
68
  ```js
68
- import korLunar from "kor-lunar";
69
+ import { toLunar } from "kor-lunar";
69
70
 
70
- // 양력 → 음력
71
- console.log(korLunar.toLunar(2025, 6, 25));
71
+ console.log(toLunar(2025, 6, 25));
72
72
  // {
73
73
  // year: 2025,
74
74
  // month: 6,
@@ -81,31 +81,75 @@ console.log(korLunar.toLunar(2025, 6, 25));
81
81
  // dayOfWeek: 3
82
82
  // }
83
83
 
84
- // 양력 → 음력 (윤달)
85
- console.log(korLunar.toLunar(2025, 7, 25));
86
- // {
87
- // year: 2025,
88
- // month: 6,
89
- // day: 1,
90
- // isLeapMonth: true,
91
- // secha: '을사',
92
- // wolgeon: '', // 윤달인 경우 월건은 빈 문자열
93
- // iljin: '을미',
94
- // julianDay: 2460882,
95
- // dayOfWeek: 5
96
- // }
84
+ // 윤달인 경우
85
+ console.log(toLunar(2025, 7, 25));
86
+ // { ..., month: 6, isLeapMonth: true, wolgeon: '' }
87
+ // 윤달인 경우 wolgeon은 빈 문자열로 반환됩니다
88
+ ```
89
+
90
+ ### 음력 → 양력 (`toSolar`)
97
91
 
98
- // 음력 → 양력
99
- console.log(korLunar.toSolar(2025, 6, 1, false));
92
+ ```js
93
+ import { toSolar } from "kor-lunar";
94
+
95
+ console.log(toSolar(2025, 6, 1, false));
100
96
  // { year: 2025, month: 6, day: 25 }
101
97
 
102
- console.log(korLunar.toSolar(2025, 6, 1, true));
98
+ console.log(toSolar(2025, 6, 1, true));
103
99
  // { year: 2025, month: 7, day: 25 }
104
100
  ```
105
101
 
106
- > 권장되진 않지만, `korLunar.LunarTable`과 `korLunar.SolarTable` 같은 내부 함수에 직접 접근할 수도 있습니다.
107
- > 이를 통해 단순 음력 변환 뿐만 아니라, 더 다양한 기능을 구현할 수 있습니다.
108
- > [예제 사이트: 음력 달력](https://kahyou22.github.io/kor-lunar-js/#lunarCalendar)
102
+ ### LunarCalendar
103
+
104
+ 음력 날짜를 다루기 위한 **불변(immutable) 클래스**입니다.
105
+ 날짜 연산, 비교, 변환 등을 지원하며,
106
+ 모든 변경 메서드는 원본을 수정하지 않고 새 객체를 반환합니다.
107
+
108
+ ```js
109
+ import { LunarCalendar } from "kor-lunar";
110
+
111
+ // 음력 날짜로 생성 (2025년 8월 15일, 추석)
112
+ const chuseok = LunarCalendar.of(2025, 8, 15);
113
+
114
+ // 속성 접근
115
+ chuseok.year; // 2025
116
+ chuseok.month; // 8
117
+ chuseok.day; // 15
118
+ chuseok.isLeapMonth; // false
119
+ chuseok.dayOfWeek; // 0 (일요일)
120
+ chuseok.secha; // '을사'
121
+ chuseok.wolgeon; // '을유'
122
+ chuseok.iljin; // '무신'
123
+
124
+ // 양력 변환
125
+ chuseok.toSolar(); // { year: 2025, month: 10, day: 6 }
126
+
127
+ // 문자열 표현
128
+ chuseok.toString(); // '2025-08-15' (윤달인 경우 2025-윤06-01)
129
+
130
+ // 날짜 연산 (원본은 변경되지 않음)
131
+ const nextDay = chuseok.addDays(1);
132
+ const nextMonth = chuseok.addMonths(1);
133
+ const nextYear = chuseok.addYears(1);
134
+
135
+ // 비교
136
+ chuseok.isBefore(nextDay); // true
137
+ chuseok.equals(chuseok); // true
138
+ nextDay.diffDays(chuseok); // 1
139
+ ```
140
+
141
+ > `korLunar.LunarTable`과 `korLunar.SolarTable`을 통해 내부 유틸 함수에 직접 접근할 수도 있습니다.
142
+ > 이를 통해 더 다양한 기능을 구현할 수 있습니다 — [예제: 음력 달력](https://kahyou22.github.io/kor-lunar-js/#lunarCalendar)
143
+
144
+ ## 기여
145
+
146
+ 버그 제보, 기능 제안, PR 등 모두 환영합니다.
147
+
148
+ - 🔍 버그 제보 → [Issues](https://github.com/kahyou22/kor-lunar-js/issues)
149
+ - 💡 기능 제안 → [Issues](https://github.com/kahyou22/kor-lunar-js/issues) 또는 [Discussions](https://github.com/kahyou22/kor-lunar-js/discussions)
150
+ - 💬 질문 · 의견 → [Discussions](https://github.com/kahyou22/kor-lunar-js/discussions)
151
+
152
+ 자유롭게 남겨주세요.
109
153
 
110
154
  ## 라이선스
111
155