lichta 1.0.0-beta → 1.0.0

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.
Files changed (2) hide show
  1. package/README.md +72 -68
  2. package/package.json +18 -5
package/README.md CHANGED
@@ -1,28 +1,32 @@
1
1
  # 🌙 LichTa
2
2
 
3
- **Thư viện chuyển đổi Dương lịch Âm lịch Việt Nam cho JavaScript/TypeScript.**
3
+ **Vietnamese SolarLunar Calendar conversion library for JavaScript/TypeScript.**
4
4
 
5
- Hỗ trợ Svelte 5 components ăn liền, đồng thời export pure TypeScript core cho React, Vue, Angular, vanilla JS.
5
+ Supports ready-to-use Svelte 5 components, while exporting a pure TypeScript core for React, Vue, Angular, and vanilla JS.
6
6
 
7
7
  [![npm version](https://img.shields.io/npm/v/lichta)](https://www.npmjs.com/package/lichta)
8
- [![license](https://img.shields.io/npm/l/lichta)](https://github.com/juststridev/lichta/blob/main/LICENSE)
8
+ [![license](https://img.shields.io/npm/l/lichta)](https://github.com/zeforc/lichta/blob/main/LICENSE)
9
+
10
+ 🚀 **[Live Demo](https://lich-ta.vercel.app/)**
11
+
12
+ > 🇻🇳 [Phiên bản Tiếng Việt (Vietnamese version)](./README.vi.md)
9
13
 
10
14
  ---
11
15
 
12
- ## ✨ Tính năng
16
+ ## ✨ Features
13
17
 
14
- - 🔄 **Chuyển đổi Solar ↔ Lunar** — Thuật toán Hồ Ngọc Đức (phạm vi 1800–2199)
15
- - 🐉 **Can Chi** — Tính Can Chi cho năm, tháng, ngày, giờ
16
- - 🔮 **Ngũ Hành & Mệnh** — Tính mệnh theo năm sinh
17
- - ⏰ **Giờ Hoàng Đạo** — 6 giờ tốt trong ngày
18
- - 📅 **Calendar Component** — Lịch tháng Svelte 5 với ngày âm lịch
19
- - 🎨 **Format** — Hiển thị ngày âm lịch truyền thống (Mùng Một tháng Giêng...)
20
- - 🌐 **i18n** — Hỗ trợ ViệtAnhNhậtHàn (vi, en, ja, ko)
18
+ - 🔄 **Solar ↔ Lunar Conversion** — Ho Ngoc Duc algorithm (range 1800–2199)
19
+ - 🐉 **Sexagenary Cycle (Can Chi)** — Calculate Can Chi for year, month, day, and hour
20
+ - 🔮 **Five Elements (Ngũ Hành)** — Calculate destiny element based on birth year
21
+ - ⏰ **Auspicious Hours (Giờ Hoàng Đạo)** — 6 auspicious hours in a day
22
+ - 📅 **Calendar Component** — Svelte 5 monthly calendar with lunar dates
23
+ - 🎨 **Format** — Display traditional lunar dates (Mùng Một tháng Giêng...)
24
+ - 🌐 **i18n** — VietnameseEnglishJapaneseKorean support (vi, en, ja, ko)
21
25
  - 📦 **Multi-framework** — Svelte 5, React, Vue, Angular, vanilla JS
22
26
 
23
27
  ---
24
28
 
25
- ## 📦 Cài đặt
29
+ ## 📦 Installation
26
30
 
27
31
  ```bash
28
32
  npm install lichta
@@ -30,16 +34,16 @@ npm install lichta
30
34
 
31
35
  ---
32
36
 
33
- ## 🚀 Sử dụng
37
+ ## 🚀 Usage
34
38
 
35
- ### Core Logic (mọi framework)
39
+ ### Core Logic (Any framework)
36
40
 
37
- Import từ `lichta/core` để sử dụng **pure TypeScript** — không phụ thuộc Svelte:
41
+ Import from `lichta/core` to use **pure TypeScript** — no Svelte dependency:
38
42
 
39
43
  ```typescript
40
44
  import { LichTa, getYearDetails } from 'lichta/core';
41
45
 
42
- // Dương lịch Âm lịch
46
+ // SolarLunar
43
47
  const lunar = LichTa.toLunar(10, 2, 2024);
44
48
  // → {
45
49
  // day: 1, month: 1, year: 2024,
@@ -50,56 +54,56 @@ const lunar = LichTa.toLunar(10, 2, 2024);
50
54
  // jd: 2460350
51
55
  // }
52
56
 
53
- // Âm lịch Dương lịch
57
+ // LunarSolar
54
58
  const solar = LichTa.toSolar(1, 1, 2024, false);
55
59
  // → { day: 10, month: 2, year: 2024 }
56
60
 
57
- // Múi giờ tùy chỉnh (mặc định GMT+7)
61
+ // Custom timezone (default is GMT+7)
58
62
  const lunarChina = LichTa.toLunar(10, 2, 2024, 8); // GMT+8
59
63
  ```
60
64
 
61
- ### Can Chi & Phong Thủy
65
+ ### Sexagenary Cycle & Feng Shui (Can Chi & Phong Thủy)
62
66
 
63
67
  ```typescript
64
68
  import { getYearDetails, getDayCanChi, getMonthCanChi, getHourCanChi, getAuspiciousHours } from 'lichta/core';
65
69
 
66
- // Can Chi + Mệnh theo năm
70
+ // Can Chi + Element for the year
67
71
  getYearDetails(2024);
68
72
  // → { can: 'Giáp', chi: 'Thìn', menh: 'Hỏa',
69
73
  // fullString: 'Giáp Thìn - Mệnh Hỏa' }
70
74
 
71
- // Can Chi ngày (cần Julian Day Number)
75
+ // Day Can Chi (requires Julian Day Number)
72
76
  const lunar = LichTa.toLunar(10, 2, 2024);
73
77
  getDayCanChi(lunar.jd); // → 'Giáp Tý'
74
78
 
75
- // Can Chi tháng
76
- getMonthCanChi(1, 2024); // → tháng Giêng năm Giáp Thìn
79
+ // Month Can Chi
80
+ getMonthCanChi(1, 2024); // → month Giêng year Giáp Thìn
77
81
 
78
- // Can Chi giờ
79
- getHourCanChi(8, lunar.jd); // → giờ Thìn (7h-9h)
82
+ // Hour Can Chi
83
+ getHourCanChi(8, lunar.jd); // → hour Thìn (7h-9h)
80
84
 
81
- // Giờ Hoàng Đạo
85
+ // Auspicious Hours
82
86
  getAuspiciousHours(lunar.jd);
83
87
  // → ['Tý', 'Sửu', 'Mão', 'Ngọ', 'Mùi', 'Dậu']
84
88
  ```
85
89
 
86
- ### Format & Hiển thị
90
+ ### Format & Display
87
91
 
88
92
  ```typescript
89
93
  import { formatTraditional, formatLunarDate, getMonthName, getDayName } from 'lichta/utils';
90
94
 
91
95
  const lunar = LichTa.toLunar(10, 2, 2024);
92
96
 
93
- // Format truyền thống
97
+ // Traditional format
94
98
  formatTraditional(lunar);
95
99
  // → 'Mùng Một tháng Giêng năm Giáp Thìn'
96
100
 
97
- // Format theo pattern
101
+ // Pattern format
98
102
  formatLunarDate(lunar, 'dd/MM/yyyy'); // → '01/01/2024'
99
103
  formatLunarDate(lunar, 'CC'); // → 'Giáp Thìn'
100
104
  formatLunarDate(lunar, 'Ngày DC'); // → 'Ngày Giáp Tý'
101
105
 
102
- // Tên truyền thống
106
+ // Traditional names
103
107
  getMonthName(1); // → 'Giêng'
104
108
  getMonthName(12); // → 'Chạp'
105
109
  getDayName(1); // → 'Mùng Một'
@@ -109,18 +113,18 @@ getDayName(30); // → 'Ba Mươi'
109
113
 
110
114
  **Format tokens:**
111
115
 
112
- | Token | Mô tả | Ví dụ |
116
+ | Token | Description | Example |
113
117
  |--------|-------------------------------|--------------|
114
- | `dd` | Ngày 2 chữ số | 01, 15 |
115
- | `d` | Ngày | 1, 15 |
116
- | `MM` | Tháng 2 chữ số | 01, 12 |
117
- | `M` | Tháng | 1, 12 |
118
- | `yyyy` | Năm 4 chữ số | 2024 |
119
- | `yy` | Năm 2 chữ số cuối | 24 |
120
- | `CC` | Can Chi năm | Giáp Thìn |
121
- | `DC` | Can Chi ngày | Giáp Tý |
122
- | `MC` | Can Chi tháng | Bính Dần |
123
- | `L` | "Nhuận" nếu tháng nhuận | Nhuận |
118
+ | `dd` | 2-digit day | 01, 15 |
119
+ | `d` | Day | 1, 15 |
120
+ | `MM` | 2-digit month | 01, 12 |
121
+ | `M` | Month | 1, 12 |
122
+ | `yyyy` | 4-digit year | 2024 |
123
+ | `yy` | Last 2 digits of year | 24 |
124
+ | `CC` | Year Can Chi | Giáp Thìn |
125
+ | `DC` | Day Can Chi | Giáp Tý |
126
+ | `MC` | Month Can Chi | Bính Dần |
127
+ | `L` | "Nhuận" if leap month | Nhuận |
124
128
 
125
129
  ### Svelte 5 Components
126
130
 
@@ -129,32 +133,32 @@ getDayName(30); // → 'Ba Mươi'
129
133
  import { Calendar, Formatter } from 'lichta';
130
134
  </script>
131
135
 
132
- <!-- Lịch tháng đầy đủ -->
136
+ <!-- Full monthly calendar -->
133
137
  <Calendar
134
138
  showLunar={true}
135
139
  locale="vi"
136
140
  onSelect={(date, lunar) => console.log(date, lunar)}
137
141
  />
138
142
 
139
- <!-- Hiển thị ngày âm lịch -->
143
+ <!-- Lunar date formatter -->
140
144
  <Formatter date={new Date()} />
141
145
  ```
142
146
 
143
147
  #### Calendar Props
144
148
 
145
- | Prop | Type | Mặc định | Mô tả |
149
+ | Prop | Type | Default | Description |
146
150
  |----------------|-----------------------------------------------|-------------------|-------------------------------|
147
- | `month` | `number` | Tháng hiện tại | Tháng hiển thị (1-12) |
148
- | `year` | `number` | Năm hiện tại | Năm hiển thị |
149
- | `selectedDate` | `Date \| null` | `null` | Ngày được chọn |
150
- | `onSelect` | `(date: Date, lunar: LunarDate) => void` | — | Callback khi chọn ngày |
151
- | `showLunar` | `boolean` | `true` | Hiển thị ngày âm lịch |
152
- | `locale` | `'vi' \| 'en' \| 'ja' \| 'ko'` | `'vi'` | Ngôn ngữ |
153
- | `dayCell` | `Snippet` | — | Custom snippet cho ô ngày |
151
+ | `month` | `number` | Current month | Displayed month (1-12) |
152
+ | `year` | `number` | Current year | Displayed year |
153
+ | `selectedDate` | `Date \| null` | `null` | Selected date |
154
+ | `onSelect` | `(date: Date, lunar: LunarDate) => void` | — | Callback on date select |
155
+ | `showLunar` | `boolean` | `true` | Show lunar dates |
156
+ | `locale` | `'vi' \| 'en' \| 'ja' \| 'ko'` | `'vi'` | Language |
157
+ | `dayCell` | `Snippet` | — | Custom snippet for day cell |
154
158
 
155
159
  #### Theming
156
160
 
157
- Calendar hỗ trợ CSS custom properties:
161
+ The Calendar supports CSS custom properties:
158
162
 
159
163
  ```css
160
164
  :root {
@@ -174,7 +178,7 @@ Calendar hỗ trợ CSS custom properties:
174
178
  ```typescript
175
179
  import { t, getZodiacAnimal } from 'lichta';
176
180
 
177
- // Lấy bộ dịch
181
+ // Get dictionary
178
182
  const vi = t('vi');
179
183
  vi.heavenlyStems; // ['Giáp', 'Ất', ...]
180
184
  vi.earthlyBranches; // ['Tý', 'Sửu', ...]
@@ -191,7 +195,7 @@ ja.weekDays; // ['日', '月', '火', '水', '木', '金', '土']
191
195
  const ko = t('ko');
192
196
  ko.fiveElements; // ['금', '목', '수', '화', '토']
193
197
 
194
- // Con giáp theo năm
198
+ // Zodiac animal by year
195
199
  getZodiacAnimal(0, 'vi'); // → 'Chuột'
196
200
  getZodiacAnimal(4, 'en'); // → 'Dragon'
197
201
  getZodiacAnimal(0, 'ja'); // → '鼠'
@@ -201,35 +205,35 @@ getZodiacAnimal(0, 'ja'); // → '鼠'
201
205
 
202
206
  ## 📁 Import Paths
203
207
 
204
- | Path | Nội dung | Dùng cho |
208
+ | Path | Content | Used for |
205
209
  |-----------------|-----------------------------------|-------------------------------|
206
- | `lichta` | Toàn bộ API + Svelte components | Svelte 5 projects |
210
+ | `lichta` | Full API + Svelte components | Svelte 5 projects |
207
211
  | `lichta/core` | Pure TypeScript logic | React, Vue, Angular, vanilla |
208
- | `lichta/utils` | Format utilities | Mọi framework |
212
+ | `lichta/utils` | Format utilities | Any framework |
209
213
 
210
214
  ```typescript
211
- // Svelte 5 — import tất cả
215
+ // Svelte 5 — import everything
212
216
  import { LichTa, Calendar, Formatter, formatTraditional } from 'lichta';
213
217
 
214
- // React / Vue / Angular — chỉ import core logic
218
+ // React / Vue / Angular — import core logic only
215
219
  import { LichTa, getYearDetails } from 'lichta/core';
216
220
  import { formatTraditional, getDayName } from 'lichta/utils';
217
221
  ```
218
222
 
219
223
  ---
220
224
 
221
- ## 📐 Thuật toán
225
+ ## 📐 Algorithm
222
226
 
223
- LichTa sử dụng thuật toán chuyển đổi âm lịch của **Hồ Ngọc Đức** (Đại học Leipzig), dựa trên:
227
+ LichTa uses the lunar conversion algorithm by **Ho Ngoc Duc** (Leipzig University), based on:
224
228
 
225
- - **Julian Day Number** — Hệ tọa độ ngày liên tục cho tính toán thiên văn
226
- - **Điểm Sóc (New Moon)** — Xác định mùng 1 âm lịch
227
- - **Trung Khí (Solar Terms)** — Xác định tháng tháng nhuận
228
- - **Jean Meeus, "Astronomical Algorithms"** — Công thức thiên văn chính xác
229
+ - **Julian Day Number** — Continuous day coordinate system for astronomical calculations
230
+ - **New Moon** — Determines the 1st day of the lunar month
231
+ - **Solar Terms** — Determines months and leap months
232
+ - **Jean Meeus, "Astronomical Algorithms"** — Precise astronomical formulas
229
233
 
230
- **Phạm vi**: 1800 – 2199 | **Múi giờ mặc định**: GMT+7 (Việt Nam)
234
+ **Range**: 1800 – 2199 | **Default timezone**: GMT+7 (Vietnam)
231
235
 
232
- Xem chi tiết trong [docs/ALGORITHM.md](./docs/ALGORITHM.md).
236
+ See details in [docs/ALGORITHM.md](./docs/ALGORITHM.md).
233
237
 
234
238
  ---
235
239
 
@@ -241,5 +245,5 @@ Xem chi tiết trong [docs/ALGORITHM.md](./docs/ALGORITHM.md).
241
245
 
242
246
  ## 🙏 Credits
243
247
 
244
- - **Hồ Ngọc Đức** — Thuật toán gốc ([informatik.uni-leipzig.de](http://www.informatik.uni-leipzig.de/~duc/amlich/))
248
+ - **Ho Ngoc Duc** — Original algorithm ([informatik.uni-leipzig.de](http://www.informatik.uni-leipzig.de/~duc/amlich/))
245
249
  - **Jean Meeus** — *Astronomical Algorithms* (1998)
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "lichta",
3
- "version": "1.0.0-beta",
3
+ "version": "1.0.0",
4
4
  "description": "Thư viện chuyển đổi Dương lịch ↔ Âm lịch Việt Nam. Vietnamese lunar calendar conversion library with Svelte 5 components.",
5
- "author": "Stridev | Gavin (Thien) N",
5
+ "author": "Zeforc | Stridev",
6
6
  "license": "MIT",
7
7
  "scripts": {
8
8
  "dev": "vite dev",
@@ -62,6 +62,9 @@
62
62
  "eslint-config-prettier": "^10.1.8",
63
63
  "eslint-plugin-svelte": "^3.19.0",
64
64
  "globals": "^17.6.0",
65
+ "lichta-event-calendar": "^1.0.0",
66
+ "lichta-full-calendar": "^1.0.0",
67
+ "lichta-react-big-calendar": "^1.0.0",
65
68
  "prettier": "^3.8.3",
66
69
  "prettier-plugin-svelte": "^4.1.0",
67
70
  "publint": "^0.3.21",
@@ -85,10 +88,20 @@
85
88
  ],
86
89
  "repository": {
87
90
  "type": "git",
88
- "url": "git+https://github.com/juststridev/lichta.git"
91
+ "url": "git+https://github.com/zeforc/lichta.git"
89
92
  },
90
93
  "bugs": {
91
- "url": "https://github.com/juststridev/lichta/issues"
94
+ "url": "https://github.com/zeforc/lichta/issues"
92
95
  },
93
- "homepage": "https://github.com/juststridev/lichta#readme"
96
+ "homepage": "https://github.com/zeforc/lichta#readme",
97
+ "dependencies": {
98
+ "@event-calendar/core": "^5.7.1",
99
+ "@event-calendar/day-grid": "^3.12.0",
100
+ "@fullcalendar/core": "^6.1.20",
101
+ "@fullcalendar/daygrid": "^6.1.20",
102
+ "moment": "^2.30.1",
103
+ "react": "^19.2.7",
104
+ "react-big-calendar": "^1.20.0",
105
+ "react-dom": "^19.2.7"
106
+ }
94
107
  }