vietnamese-lunar 2.1.1 → 2.2.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.
- package/CHANGELOG.md +16 -1
- package/lib/cjs/dayStar.d.ts +3 -2
- package/lib/cjs/dayStar.js +11 -6
- package/lib/cjs/index.d.ts +1 -1
- package/lib/cjs/lunarConverter.js +2 -1
- package/lib/cjs/type.d.ts +10 -0
- package/lib/esm/dayStar.d.ts +3 -2
- package/lib/esm/dayStar.js +9 -5
- package/lib/esm/index.d.ts +1 -1
- package/lib/esm/lunarConverter.js +2 -1
- package/lib/esm/type.d.ts +10 -0
- package/package.json +1 -1
- package/readme.md +69 -6
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this package are documented here. Versions follow [Semantic Versioning](https://semver.org/): a **major** bump (1.x → 2.x) means you may need to change your code.
|
|
4
4
|
|
|
5
|
+
## 2.2.0 — 2026-11-01
|
|
6
|
+
|
|
7
|
+
Backward compatible with 2.1.1: the default behaviour and every existing field are unchanged.
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- `dayInfo(date, {monthBasis: 'solar-term' | 'lunar-month'})` — how the month branch (Nguyệt Kiến) used for the day star is determined. Default `'solar-term'` (unchanged); `'lunar-month'` follows the lunar month number (tháng 1 → Dần), as many Vietnamese almanac sites do. Also `getDayStarInfo(lunar, system?, monthBasis?)`.
|
|
12
|
+
- `dayStar.monthBasis`: the basis used for that result (new field, always present).
|
|
13
|
+
- New exported type `MonthBasis`; `DayInfoOptions` gains `monthBasis`.
|
|
14
|
+
- README: comparison table and examples generated from real output. Over 2025 the two bases give a different day star on 118 of 365 days; they differ by exactly one month branch on those days (between a solar term and the next mùng 1, or the reverse).
|
|
15
|
+
|
|
16
|
+
### Notes
|
|
17
|
+
|
|
18
|
+
- `hours[].star` / `category` and the auspicious-hour strings are **not** affected by `monthBasis`: the hour-star rule depends on the day's Chi only (verified over 730 days). The original request listed them under `monthBasis`; applying it there would need a month-dependent hour rule that this library does not use.
|
|
19
|
+
|
|
5
20
|
## 2.1.1 — 2026-11-01
|
|
6
21
|
|
|
7
22
|
### ⚠️ Behaviour changes (relative to 2.1.0)
|
|
@@ -46,7 +61,7 @@ Checked by running 2.1.0 and this version side by side on 20,863 dates (every 7t
|
|
|
46
61
|
|
|
47
62
|
### Not in this release
|
|
48
63
|
|
|
49
|
-
- `monthBasis
|
|
64
|
+
- `monthBasis` for `dayStar` — shipped in 2.2.0.
|
|
50
65
|
|
|
51
66
|
## 2.1.0 — 2026-11-01
|
|
52
67
|
|
package/lib/cjs/dayStar.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DayStarInfo, LunarDate, StarCategory, StarSystem } from "./type.js";
|
|
1
|
+
import { DayStarInfo, LunarDate, MonthBasis, StarCategory, StarSystem } from "./type.js";
|
|
2
2
|
type StarDefinition = {
|
|
3
3
|
name: string;
|
|
4
4
|
aliases: string[];
|
|
@@ -9,6 +9,7 @@ type StarDefinition = {
|
|
|
9
9
|
};
|
|
10
10
|
export declare const STAR_DEFINITIONS: StarDefinition[];
|
|
11
11
|
export declare const getStarCategory: (starIndex: number, system: StarSystem) => StarCategory;
|
|
12
|
+
export declare const getMonthZhi: (lunarDate: LunarDate, basis: MonthBasis) => number;
|
|
12
13
|
export declare const getHourStarPosition: (julianDay: number, hourBranch: number) => number;
|
|
13
|
-
export declare const getDayStarInfo: (lunarDate: LunarDate, system?: StarSystem) => DayStarInfo;
|
|
14
|
+
export declare const getDayStarInfo: (lunarDate: LunarDate, system?: StarSystem, monthBasis?: MonthBasis) => DayStarInfo;
|
|
14
15
|
export {};
|
package/lib/cjs/dayStar.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getDayStarInfo = exports.getHourStarPosition = exports.getStarCategory = exports.STAR_DEFINITIONS = void 0;
|
|
3
|
+
exports.getDayStarInfo = exports.getHourStarPosition = exports.getMonthZhi = exports.getStarCategory = exports.STAR_DEFINITIONS = void 0;
|
|
4
4
|
const constants_js_1 = require("./constants.js");
|
|
5
5
|
const heavenly_earthly_js_1 = require("./heavenly_earthly.js");
|
|
6
6
|
// Vị trí sao Thanh Long trên Chi ngày, theo Nguyệt Kiến (Chi của tháng tiết khí hiện tại).
|
|
@@ -34,9 +34,13 @@ const getStarCategory = (starIndex, system) => {
|
|
|
34
34
|
return system === 'ngoc-hap' ? def.ngocHap : def.hiepKy;
|
|
35
35
|
};
|
|
36
36
|
exports.getStarCategory = getStarCategory;
|
|
37
|
+
// Chi của tháng (Tý=0 ... Hợi=11) theo cách tính `basis`. Tháng âm 1 → Dần (2), nên Chi = (tháng + 1) % 12.
|
|
38
|
+
const getMonthZhi = (lunarDate, basis) => basis === 'lunar-month' ? (lunarDate.month + 1) % 12 : (0, heavenly_earthly_js_1.getMonthBranchIndex)(lunarDate.julianDay);
|
|
39
|
+
exports.getMonthZhi = getMonthZhi;
|
|
37
40
|
// Vị trí (0..11) của thần trực ngày.
|
|
38
|
-
const getDayStarPosition = (
|
|
39
|
-
const
|
|
41
|
+
const getDayStarPosition = (lunarDate, basis) => {
|
|
42
|
+
const julianDay = lunarDate.julianDay;
|
|
43
|
+
const thanhLongChiIndex = THANH_LONG_OFFSET_BY_MONTH_ZHI[(0, exports.getMonthZhi)(lunarDate, basis)];
|
|
40
44
|
return ((0, heavenly_earthly_js_1.getDayBranchIndex)(julianDay) - thanhLongChiIndex + 12) % 12;
|
|
41
45
|
};
|
|
42
46
|
// Vị trí (0..11) của thần trực giờ `hourBranch` (0 = Tý ... 11 = Hợi) của ngày.
|
|
@@ -45,11 +49,11 @@ const getHourStarPosition = (julianDay, hourBranch) => {
|
|
|
45
49
|
return (hourBranch - start + 12) % 12;
|
|
46
50
|
};
|
|
47
51
|
exports.getHourStarPosition = getHourStarPosition;
|
|
48
|
-
const getDayStarInfo = (lunarDate, system = 'hiep-ky') => {
|
|
52
|
+
const getDayStarInfo = (lunarDate, system = 'hiep-ky', monthBasis = 'solar-term') => {
|
|
49
53
|
if (lunarDate.date === 0) {
|
|
50
|
-
return { star: '', isAuspicious: false, index: 0, category: null, system, aliases: [] };
|
|
54
|
+
return { star: '', isAuspicious: false, index: 0, category: null, system, monthBasis, aliases: [] };
|
|
51
55
|
}
|
|
52
|
-
const position = getDayStarPosition(lunarDate
|
|
56
|
+
const position = getDayStarPosition(lunarDate, monthBasis);
|
|
53
57
|
const def = exports.STAR_DEFINITIONS[position];
|
|
54
58
|
const category = (0, exports.getStarCategory)(position, system);
|
|
55
59
|
return {
|
|
@@ -58,6 +62,7 @@ const getDayStarInfo = (lunarDate, system = 'hiep-ky') => {
|
|
|
58
62
|
index: position + 1,
|
|
59
63
|
category,
|
|
60
64
|
system,
|
|
65
|
+
monthBasis,
|
|
61
66
|
aliases: def.aliases.slice(),
|
|
62
67
|
};
|
|
63
68
|
};
|
package/lib/cjs/index.d.ts
CHANGED
|
@@ -6,4 +6,4 @@ export { getDayStarInfo } from './dayStar.js';
|
|
|
6
6
|
export { getSolarTerms, getSolarTermByIndex } from './solarTerms.js';
|
|
7
7
|
export { getHolidays, nextHolidays } from './holidays.js';
|
|
8
8
|
export { HEAVENLY_STEMS, EARTHLY_BRANCHES, SOLAR_TERMS } from './constants.js';
|
|
9
|
-
export type { LunarDate, DayInfo, LunarDayInfo, DayStarInfo, Holiday, dateFormat, StarSystem, StarCategory, HolidayType, HolidayEvent, HourInfo, SolarTermItem, SolarTermInfo, CanChiInfo, CanChiPart, Element, DayInfoOptions, DateInput, LocalDateTime, NextHolidaysOptions, SolarDateObject, SolarDateResult, } from './type.js';
|
|
9
|
+
export type { LunarDate, DayInfo, LunarDayInfo, DayStarInfo, Holiday, dateFormat, StarSystem, StarCategory, MonthBasis, HolidayType, HolidayEvent, HourInfo, SolarTermItem, SolarTermInfo, CanChiInfo, CanChiPart, Element, DayInfoOptions, DateInput, LocalDateTime, NextHolidaysOptions, SolarDateObject, SolarDateResult, } from './type.js';
|
|
@@ -25,6 +25,7 @@ const getElement = (napAm) => {
|
|
|
25
25
|
};
|
|
26
26
|
const buildDayInfo = (day, month, year, options) => {
|
|
27
27
|
const system = (options === null || options === void 0 ? void 0 : options.starSystem) === 'ngoc-hap' ? 'ngoc-hap' : 'hiep-ky';
|
|
28
|
+
const monthBasis = (options === null || options === void 0 ? void 0 : options.monthBasis) === 'lunar-month' ? 'lunar-month' : 'solar-term';
|
|
28
29
|
const lunar = (0, lunar_js_1.getLunarDate)(day, month, year);
|
|
29
30
|
const lunarText = getDayName(lunar);
|
|
30
31
|
const jd = lunar.julianDay;
|
|
@@ -44,7 +45,7 @@ const buildDayInfo = (day, month, year, options) => {
|
|
|
44
45
|
dayMaster: napAm,
|
|
45
46
|
napAm,
|
|
46
47
|
element: getElement(napAm),
|
|
47
|
-
dayStar: (0, dayStar_js_1.getDayStarInfo)(lunar, system),
|
|
48
|
+
dayStar: (0, dayStar_js_1.getDayStarInfo)(lunar, system, monthBasis),
|
|
48
49
|
holidays: (0, holidays_js_1.getVietnameseHolidays)(day, month, year, lunar, nextSolar),
|
|
49
50
|
hours: (0, auspiciousHours_js_1.getHours)(jd, system),
|
|
50
51
|
solarTerm: (0, solarTerms_js_1.getSolarTermInfo)(jd),
|
package/lib/cjs/type.d.ts
CHANGED
|
@@ -15,6 +15,12 @@ export type dateFormat = {
|
|
|
15
15
|
/** Hệ thống phân loại Hoàng Đạo / Hắc Đạo. */
|
|
16
16
|
export type StarSystem = 'hiep-ky' | 'ngoc-hap';
|
|
17
17
|
export type StarCategory = 'hoang-dao' | 'hac-dao' | null;
|
|
18
|
+
/**
|
|
19
|
+
* Cách xác định Nguyệt Kiến (Chi của tháng) khi tính thần trực ngày:
|
|
20
|
+
* - `'solar-term'` (mặc định): theo tiết khí (Lập Xuân → Dần, Kinh Trập → Mão, ...), đúng sách cổ.
|
|
21
|
+
* - `'lunar-month'`: theo số tháng âm lịch (tháng 1 → Dần, tháng 2 → Mão, ...); tháng nhuận dùng chung Chi với tháng cùng số.
|
|
22
|
+
*/
|
|
23
|
+
export type MonthBasis = 'solar-term' | 'lunar-month';
|
|
18
24
|
export type DayStarInfo = {
|
|
19
25
|
star: string;
|
|
20
26
|
/** Giữ cho tương thích 2.x. `false` KHÔNG đồng nghĩa hắc đạo — xem `category`. */
|
|
@@ -23,6 +29,8 @@ export type DayStarInfo = {
|
|
|
23
29
|
index: number;
|
|
24
30
|
category: StarCategory;
|
|
25
31
|
system: StarSystem;
|
|
32
|
+
/** Cách tính Nguyệt Kiến đã dùng cho kết quả này. */
|
|
33
|
+
monthBasis: MonthBasis;
|
|
26
34
|
aliases: string[];
|
|
27
35
|
};
|
|
28
36
|
export type HolidayType = 'public' | 'traditional' | 'commemorative';
|
|
@@ -118,6 +126,8 @@ export type NextHolidaysOptions = {
|
|
|
118
126
|
};
|
|
119
127
|
export type DayInfoOptions = {
|
|
120
128
|
starSystem?: StarSystem;
|
|
129
|
+
/** Mặc định `'solar-term'`. Chỉ ảnh hưởng `dayStar`; `hours[]` không phụ thuộc tháng nên không đổi. */
|
|
130
|
+
monthBasis?: MonthBasis;
|
|
121
131
|
};
|
|
122
132
|
export type DayInfo = {
|
|
123
133
|
day: string;
|
package/lib/esm/dayStar.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DayStarInfo, LunarDate, StarCategory, StarSystem } from "./type.js";
|
|
1
|
+
import { DayStarInfo, LunarDate, MonthBasis, StarCategory, StarSystem } from "./type.js";
|
|
2
2
|
type StarDefinition = {
|
|
3
3
|
name: string;
|
|
4
4
|
aliases: string[];
|
|
@@ -9,6 +9,7 @@ type StarDefinition = {
|
|
|
9
9
|
};
|
|
10
10
|
export declare const STAR_DEFINITIONS: StarDefinition[];
|
|
11
11
|
export declare const getStarCategory: (starIndex: number, system: StarSystem) => StarCategory;
|
|
12
|
+
export declare const getMonthZhi: (lunarDate: LunarDate, basis: MonthBasis) => number;
|
|
12
13
|
export declare const getHourStarPosition: (julianDay: number, hourBranch: number) => number;
|
|
13
|
-
export declare const getDayStarInfo: (lunarDate: LunarDate, system?: StarSystem) => DayStarInfo;
|
|
14
|
+
export declare const getDayStarInfo: (lunarDate: LunarDate, system?: StarSystem, monthBasis?: MonthBasis) => DayStarInfo;
|
|
14
15
|
export {};
|
package/lib/esm/dayStar.js
CHANGED
|
@@ -30,9 +30,12 @@ export const getStarCategory = (starIndex, system) => {
|
|
|
30
30
|
return null;
|
|
31
31
|
return system === 'ngoc-hap' ? def.ngocHap : def.hiepKy;
|
|
32
32
|
};
|
|
33
|
+
// Chi của tháng (Tý=0 ... Hợi=11) theo cách tính `basis`. Tháng âm 1 → Dần (2), nên Chi = (tháng + 1) % 12.
|
|
34
|
+
export const getMonthZhi = (lunarDate, basis) => basis === 'lunar-month' ? (lunarDate.month + 1) % 12 : getMonthBranchIndex(lunarDate.julianDay);
|
|
33
35
|
// Vị trí (0..11) của thần trực ngày.
|
|
34
|
-
const getDayStarPosition = (
|
|
35
|
-
const
|
|
36
|
+
const getDayStarPosition = (lunarDate, basis) => {
|
|
37
|
+
const julianDay = lunarDate.julianDay;
|
|
38
|
+
const thanhLongChiIndex = THANH_LONG_OFFSET_BY_MONTH_ZHI[getMonthZhi(lunarDate, basis)];
|
|
36
39
|
return (getDayBranchIndex(julianDay) - thanhLongChiIndex + 12) % 12;
|
|
37
40
|
};
|
|
38
41
|
// Vị trí (0..11) của thần trực giờ `hourBranch` (0 = Tý ... 11 = Hợi) của ngày.
|
|
@@ -40,11 +43,11 @@ export const getHourStarPosition = (julianDay, hourBranch) => {
|
|
|
40
43
|
const start = THANH_LONG_HOUR_BY_DAY_ZHI[getDayBranchIndex(julianDay) % 6];
|
|
41
44
|
return (hourBranch - start + 12) % 12;
|
|
42
45
|
};
|
|
43
|
-
export const getDayStarInfo = (lunarDate, system = 'hiep-ky') => {
|
|
46
|
+
export const getDayStarInfo = (lunarDate, system = 'hiep-ky', monthBasis = 'solar-term') => {
|
|
44
47
|
if (lunarDate.date === 0) {
|
|
45
|
-
return { star: '', isAuspicious: false, index: 0, category: null, system, aliases: [] };
|
|
48
|
+
return { star: '', isAuspicious: false, index: 0, category: null, system, monthBasis, aliases: [] };
|
|
46
49
|
}
|
|
47
|
-
const position = getDayStarPosition(lunarDate
|
|
50
|
+
const position = getDayStarPosition(lunarDate, monthBasis);
|
|
48
51
|
const def = STAR_DEFINITIONS[position];
|
|
49
52
|
const category = getStarCategory(position, system);
|
|
50
53
|
return {
|
|
@@ -53,6 +56,7 @@ export const getDayStarInfo = (lunarDate, system = 'hiep-ky') => {
|
|
|
53
56
|
index: position + 1,
|
|
54
57
|
category,
|
|
55
58
|
system,
|
|
59
|
+
monthBasis,
|
|
56
60
|
aliases: def.aliases.slice(),
|
|
57
61
|
};
|
|
58
62
|
};
|
package/lib/esm/index.d.ts
CHANGED
|
@@ -6,4 +6,4 @@ export { getDayStarInfo } from './dayStar.js';
|
|
|
6
6
|
export { getSolarTerms, getSolarTermByIndex } from './solarTerms.js';
|
|
7
7
|
export { getHolidays, nextHolidays } from './holidays.js';
|
|
8
8
|
export { HEAVENLY_STEMS, EARTHLY_BRANCHES, SOLAR_TERMS } from './constants.js';
|
|
9
|
-
export type { LunarDate, DayInfo, LunarDayInfo, DayStarInfo, Holiday, dateFormat, StarSystem, StarCategory, HolidayType, HolidayEvent, HourInfo, SolarTermItem, SolarTermInfo, CanChiInfo, CanChiPart, Element, DayInfoOptions, DateInput, LocalDateTime, NextHolidaysOptions, SolarDateObject, SolarDateResult, } from './type.js';
|
|
9
|
+
export type { LunarDate, DayInfo, LunarDayInfo, DayStarInfo, Holiday, dateFormat, StarSystem, StarCategory, MonthBasis, HolidayType, HolidayEvent, HourInfo, SolarTermItem, SolarTermInfo, CanChiInfo, CanChiPart, Element, DayInfoOptions, DateInput, LocalDateTime, NextHolidaysOptions, SolarDateObject, SolarDateResult, } from './type.js';
|
|
@@ -22,6 +22,7 @@ const getElement = (napAm) => {
|
|
|
22
22
|
};
|
|
23
23
|
const buildDayInfo = (day, month, year, options) => {
|
|
24
24
|
const system = (options === null || options === void 0 ? void 0 : options.starSystem) === 'ngoc-hap' ? 'ngoc-hap' : 'hiep-ky';
|
|
25
|
+
const monthBasis = (options === null || options === void 0 ? void 0 : options.monthBasis) === 'lunar-month' ? 'lunar-month' : 'solar-term';
|
|
25
26
|
const lunar = getLunarDate(day, month, year);
|
|
26
27
|
const lunarText = getDayName(lunar);
|
|
27
28
|
const jd = lunar.julianDay;
|
|
@@ -41,7 +42,7 @@ const buildDayInfo = (day, month, year, options) => {
|
|
|
41
42
|
dayMaster: napAm,
|
|
42
43
|
napAm,
|
|
43
44
|
element: getElement(napAm),
|
|
44
|
-
dayStar: getDayStarInfo(lunar, system),
|
|
45
|
+
dayStar: getDayStarInfo(lunar, system, monthBasis),
|
|
45
46
|
holidays: getVietnameseHolidays(day, month, year, lunar, nextSolar),
|
|
46
47
|
hours: getHours(jd, system),
|
|
47
48
|
solarTerm: getSolarTermInfo(jd),
|
package/lib/esm/type.d.ts
CHANGED
|
@@ -15,6 +15,12 @@ export type dateFormat = {
|
|
|
15
15
|
/** Hệ thống phân loại Hoàng Đạo / Hắc Đạo. */
|
|
16
16
|
export type StarSystem = 'hiep-ky' | 'ngoc-hap';
|
|
17
17
|
export type StarCategory = 'hoang-dao' | 'hac-dao' | null;
|
|
18
|
+
/**
|
|
19
|
+
* Cách xác định Nguyệt Kiến (Chi của tháng) khi tính thần trực ngày:
|
|
20
|
+
* - `'solar-term'` (mặc định): theo tiết khí (Lập Xuân → Dần, Kinh Trập → Mão, ...), đúng sách cổ.
|
|
21
|
+
* - `'lunar-month'`: theo số tháng âm lịch (tháng 1 → Dần, tháng 2 → Mão, ...); tháng nhuận dùng chung Chi với tháng cùng số.
|
|
22
|
+
*/
|
|
23
|
+
export type MonthBasis = 'solar-term' | 'lunar-month';
|
|
18
24
|
export type DayStarInfo = {
|
|
19
25
|
star: string;
|
|
20
26
|
/** Giữ cho tương thích 2.x. `false` KHÔNG đồng nghĩa hắc đạo — xem `category`. */
|
|
@@ -23,6 +29,8 @@ export type DayStarInfo = {
|
|
|
23
29
|
index: number;
|
|
24
30
|
category: StarCategory;
|
|
25
31
|
system: StarSystem;
|
|
32
|
+
/** Cách tính Nguyệt Kiến đã dùng cho kết quả này. */
|
|
33
|
+
monthBasis: MonthBasis;
|
|
26
34
|
aliases: string[];
|
|
27
35
|
};
|
|
28
36
|
export type HolidayType = 'public' | 'traditional' | 'commemorative';
|
|
@@ -118,6 +126,8 @@ export type NextHolidaysOptions = {
|
|
|
118
126
|
};
|
|
119
127
|
export type DayInfoOptions = {
|
|
120
128
|
starSystem?: StarSystem;
|
|
129
|
+
/** Mặc định `'solar-term'`. Chỉ ảnh hưởng `dayStar`; `hours[]` không phụ thuộc tháng nên không đổi. */
|
|
130
|
+
monthBasis?: MonthBasis;
|
|
121
131
|
};
|
|
122
132
|
export type DayInfo = {
|
|
123
133
|
day: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vietnamese-lunar",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"description": "Vietnamese lunar calendar: solar to lunar conversion, Can Chi, solar terms, Hoàng Đạo days and Vietnamese holidays",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/esm/index.js",
|
package/readme.md
CHANGED
|
@@ -85,6 +85,7 @@ outputs:
|
|
|
85
85
|
index: 4,
|
|
86
86
|
category: "hac-dao",
|
|
87
87
|
system: "hiep-ky",
|
|
88
|
+
monthBasis: "solar-term",
|
|
88
89
|
aliases: []
|
|
89
90
|
},
|
|
90
91
|
holidays: [],
|
|
@@ -170,6 +171,7 @@ Fields of `dayInfo()`. Fields marked *(2.1.0)* / *(2.1.1)* were added in that ve
|
|
|
170
171
|
| dayStar.star | name of the day star (e.g. Thanh Long, Bạch Hổ) |
|
|
171
172
|
| dayStar.isAuspicious | kept for 2.x: true iff `category === "hoang-dao"`. **`false` does not mean hắc đạo** — see `category` |
|
|
172
173
|
| dayStar.index / category / system / aliases | *(2.1.0)* 1..12 (Thanh Long = 1), `"hoang-dao" \| "hac-dao" \| null`, `"hiep-ky" \| "ngoc-hap"`, alternative names |
|
|
174
|
+
| dayStar.monthBasis | *(2.2.0)* how the month branch (Nguyệt Kiến) was determined: `"solar-term"` (default) or `"lunar-month"` |
|
|
173
175
|
| solarTerm | *(2.1.0)* `{current, next}` |
|
|
174
176
|
| solarTerm.current / next | `{name, index, start, startLocal}`; `next` also has `daysUntil` |
|
|
175
177
|
| solarTerm.*.index | position in `SOLAR_TERMS` (0 = Xuân Phân) |
|
|
@@ -193,10 +195,56 @@ Fields of `dayInfo()`. Fields marked *(2.1.0)* / *(2.1.1)* were added in that ve
|
|
|
193
195
|
|
|
194
196
|
Items of `getHolidays()` / `nextHolidays()` are *events*, not the `holidays[]` entries above: `{name, date: {day, month, year}, calendar, lunarDate?: {day, month}, type, isDayOff, isPublicHoliday}`, plus `endDate` and `days` when `groupConsecutive` is on.
|
|
195
197
|
|
|
196
|
-
> **Note on `dayStar`:** the 12-star "Nguyệt Kiến" (month-branch) is derived from solar terms (same method used for `solarTerms`), per the classical "Thanh Long Hoàng Đạo Ca" (Hiệp Kỷ Biện Phương Thư).
|
|
198
|
+
> **Note on `dayStar`:** by default the 12-star "Nguyệt Kiến" (month-branch) is derived from solar terms (same method used for `solarTerms`), per the classical "Thanh Long Hoàng Đạo Ca" (Hiệp Kỷ Biện Phương Thư). Many popular Vietnamese almanac sites key it off the lunar month number instead, which disagrees for about a third of all days — see `monthBasis` under "New in 2.2.0".
|
|
197
199
|
|
|
198
200
|
> **Note on `holidays`:** lunar holidays are only reported in regular (non-leap) months, so they occur once per lunar year. A solar and a lunar holiday can fall on the same day (e.g. 2/9/2020 was also Lễ Vu Lan); both are returned. Solar observances are only reported from the year they were established (e.g. Ngày Văn hóa Việt Nam 24/11 from 2026, per Nghị quyết 28/2026/QH16). `isPublicHoliday` reflects the current Labor Code, Art. 112. Movable days off (the extra Quốc khánh day on 1/9 or 3/9, and the 5 Tết days chosen each year by the government) are not included.
|
|
199
201
|
|
|
202
|
+
## 🆕 New in 2.2.0
|
|
203
|
+
|
|
204
|
+
### `monthBasis` for `dayStar`
|
|
205
|
+
|
|
206
|
+
`dayInfo(date, {monthBasis: "solar-term" | "lunar-month"})` — default `"solar-term"`, so existing results do not change. The chosen basis is echoed in `dayStar.monthBasis`. `getDayStarInfo(lunar, system?, monthBasis?)` takes it as a third argument.
|
|
207
|
+
|
|
208
|
+
| | `solar-term` (default) | `lunar-month` |
|
|
209
|
+
|---|---|---|
|
|
210
|
+
| Month branch (Nguyệt Kiến) | from the current solar term: Lập Xuân → Dần, Kinh Trập → Mão, Thanh Minh → Thìn … | from the lunar month number: tháng 1 → Dần, tháng 2 → Mão, tháng 3 → Thìn … |
|
|
211
|
+
| Leap month | not applicable (follows the sun) | same branch as the regular month with the same number |
|
|
212
|
+
| Source | classical rule; same as `solarTerms` | what many Vietnamese almanac websites show |
|
|
213
|
+
| Changes when | the Sun crosses a 30° boundary (~every 30 days, around the 4th–8th of each solar month) | on mùng 1 of each lunar month |
|
|
214
|
+
|
|
215
|
+
The two bases use the same star sequence and the same Hoàng Đạo / Hắc Đạo classification; they only differ in which month branch they start from. On the days when the two month branches agree the results are identical; on the others they differ by exactly one branch, i.e. between a solar term and the next mùng 1 (or the reverse), which is up to ~16 days around each boundary.
|
|
216
|
+
|
|
217
|
+
<!-- example:month-basis -->
|
|
218
|
+
| Solar date | Lunar | `solar-term` (default): month branch → day star | `lunar-month`: month branch → day star |
|
|
219
|
+
|---|---|---|---|
|
|
220
|
+
| 1/1/2025 | 2/12 | tháng Tý → Tư Mệnh (hoang-dao) | tháng Sửu → Thiên Lao (hac-dao) |
|
|
221
|
+
| 4/1/2025 | 5/12 | tháng Tý → Minh Đường (hoang-dao) | tháng Sửu → Câu Trận (hac-dao) |
|
|
222
|
+
| 30/1/2025 | 2/1 | tháng Sửu → Minh Đường (hoang-dao) | tháng Dần → Câu Trận (hac-dao) |
|
|
223
|
+
| 17/10/2025 | 26/8 | tháng Tuất → Chu Tước (hac-dao) | tháng Dậu → Thiên Đức (hoang-dao) |
|
|
224
|
+
|
|
225
|
+
In 2025 the two bases give a different day star on **118 of 365 days**.
|
|
226
|
+
<!-- /example -->
|
|
227
|
+
|
|
228
|
+
<!-- example:month-basis-usage -->
|
|
229
|
+
```javascript
|
|
230
|
+
dayInfo("1/1/2025", {monthBasis: "lunar-month"}).dayStar
|
|
231
|
+
// → {
|
|
232
|
+
// star: "Thiên Lao",
|
|
233
|
+
// isAuspicious: false,
|
|
234
|
+
// index: 9,
|
|
235
|
+
// category: "hac-dao",
|
|
236
|
+
// system: "hiep-ky",
|
|
237
|
+
// monthBasis: "lunar-month",
|
|
238
|
+
// aliases: []
|
|
239
|
+
// }
|
|
240
|
+
|
|
241
|
+
getDayStarInfo(getLunarDate(1, 1, 2025), "hiep-ky", "lunar-month").monthBasis
|
|
242
|
+
// → "lunar-month"
|
|
243
|
+
```
|
|
244
|
+
<!-- /example -->
|
|
245
|
+
|
|
246
|
+
`monthBasis` only affects `dayStar`. The hour stars in `hours[]` depend on the day's Chi alone, not on the month, so `hours[]` (and `auspiciousHours` / `inAuspiciousHours`) are the same for both bases. *(The request this release implements asked for `hours[].star` / `category` to follow `monthBasis`; they cannot, because the rule used for hours has no month input.)*
|
|
247
|
+
|
|
200
248
|
## 🆕 New in 2.1.1
|
|
201
249
|
|
|
202
250
|
Fixes and clarifications on top of 2.1.0 (the first three bullets change behaviour — see [CHANGELOG.md](CHANGELOG.md)):
|
|
@@ -225,6 +273,7 @@ dayInfo("17/10/2025", {starSystem: "ngoc-hap"}).dayStar
|
|
|
225
273
|
// index: 4,
|
|
226
274
|
// category: "hac-dao",
|
|
227
275
|
// system: "ngoc-hap",
|
|
276
|
+
// monthBasis: "solar-term",
|
|
228
277
|
// aliases: []
|
|
229
278
|
// }
|
|
230
279
|
```
|
|
@@ -450,7 +499,7 @@ Item 10 of the upgrade request (12 Trực, 28 Sao, ngày kỵ, `rating`) is inte
|
|
|
450
499
|
|
|
451
500
|
```html
|
|
452
501
|
<script type="module">
|
|
453
|
-
import {dayInfo} from "https://cdn.jsdelivr.net/npm/vietnamese-lunar@2.
|
|
502
|
+
import {dayInfo} from "https://cdn.jsdelivr.net/npm/vietnamese-lunar@2.2.0/lib/esm/index.js";
|
|
454
503
|
</script>
|
|
455
504
|
```
|
|
456
505
|
|
|
@@ -568,7 +617,7 @@ SOLAR_TERMS[getSolarTermIndex(jd)]; // "Hàn Lộ"
|
|
|
568
617
|
|
|
569
618
|
> `getMonthBranchIndex` (solar-term month, changes at Lập Xuân, Kinh Trập…) is **not** the same as `lunarDateText.month` (lunar month, changes on mùng 1). E.g. 17/10/2025 is lunar month Ất **Dậu** but Nguyệt Kiến **Tuất**.
|
|
570
619
|
|
|
571
|
-
**`getDayStarInfo(lunar: LunarDate, system?: "hiep-ky" | "ngoc-hap"): DayStarInfo`** — 12-star Hoàng Đạo / Hắc Đạo. `system` defaults to `"hiep-ky"`.
|
|
620
|
+
**`getDayStarInfo(lunar: LunarDate, system?: "hiep-ky" | "ngoc-hap", monthBasis?: "solar-term" | "lunar-month"): DayStarInfo`** — 12-star Hoàng Đạo / Hắc Đạo. `system` defaults to `"hiep-ky"`, `monthBasis` to `"solar-term"`.
|
|
572
621
|
|
|
573
622
|
<!-- example:low-getDayStarInfo -->
|
|
574
623
|
```javascript
|
|
@@ -579,6 +628,7 @@ getDayStarInfo(getLunarDate(17, 10, 2025)) // default system: "hiep-k
|
|
|
579
628
|
// index: 4,
|
|
580
629
|
// category: "hac-dao",
|
|
581
630
|
// system: "hiep-ky",
|
|
631
|
+
// monthBasis: "solar-term",
|
|
582
632
|
// aliases: []
|
|
583
633
|
// }
|
|
584
634
|
|
|
@@ -589,8 +639,20 @@ getDayStarInfo(getLunarDate(17, 10, 2025), "ngoc-hap")
|
|
|
589
639
|
// index: 4,
|
|
590
640
|
// category: "hac-dao",
|
|
591
641
|
// system: "ngoc-hap",
|
|
642
|
+
// monthBasis: "solar-term",
|
|
592
643
|
// aliases: []
|
|
593
644
|
// }
|
|
645
|
+
|
|
646
|
+
getDayStarInfo(getLunarDate(17, 10, 2025), "hiep-ky", "lunar-month")
|
|
647
|
+
// → {
|
|
648
|
+
// star: "Thiên Đức",
|
|
649
|
+
// isAuspicious: true,
|
|
650
|
+
// index: 6,
|
|
651
|
+
// category: "hoang-dao",
|
|
652
|
+
// system: "hiep-ky",
|
|
653
|
+
// monthBasis: "lunar-month",
|
|
654
|
+
// aliases: [ "Bảo Quang", "Kim Đường" ]
|
|
655
|
+
// }
|
|
594
656
|
```
|
|
595
657
|
<!-- /example -->
|
|
596
658
|
|
|
@@ -604,17 +666,18 @@ The lists of hoàng đạo / hắc đạo stars for each system are in the table
|
|
|
604
666
|
import type {
|
|
605
667
|
DayInfo, LunarDayInfo, LunarDate, DayStarInfo, Holiday, dateFormat,
|
|
606
668
|
DateInput, DayInfoOptions, HourInfo, SolarTermItem, SolarTermInfo, CanChiInfo,
|
|
607
|
-
HolidayEvent, NextHolidaysOptions, StarSystem, StarCategory, HolidayType, LocalDateTime,
|
|
669
|
+
HolidayEvent, NextHolidaysOptions, StarSystem, StarCategory, MonthBasis, HolidayType, LocalDateTime,
|
|
608
670
|
} from "vietnamese-lunar";
|
|
609
671
|
```
|
|
610
672
|
|
|
611
673
|
| Type | Shape |
|
|
612
674
|
|---|---|
|
|
613
675
|
| `DateInput` | `string \| Date \| {day, month, year}` |
|
|
614
|
-
| `DayInfoOptions` | `{ starSystem?: "hiep-ky" \| "ngoc-hap" }` |
|
|
676
|
+
| `DayInfoOptions` | `{ starSystem?: "hiep-ky" \| "ngoc-hap", monthBasis?: "solar-term" \| "lunar-month" }` |
|
|
677
|
+
| `MonthBasis` | `"solar-term" \| "lunar-month"` |
|
|
615
678
|
| `LunarDate` | `{ date, month, year, isLeap, julianDay, monthDays }` |
|
|
616
679
|
| `dateFormat` | `{ date, month, year }` — ganzhi names |
|
|
617
|
-
| `DayStarInfo` | `{ star, isAuspicious, index, category, system, aliases }` |
|
|
680
|
+
| `DayStarInfo` | `{ star, isAuspicious, index, category, system, monthBasis, aliases }` |
|
|
618
681
|
| `Holiday` | one entry of `dayInfo().holidays`: `{ name, calendar, isPublicHoliday, type, isDayOff }` |
|
|
619
682
|
| `HolidayEvent` | item of `getHolidays` / `nextHolidays`: `{ name, date, calendar, lunarDate?, type, isDayOff, isPublicHoliday, endDate?, days? }` |
|
|
620
683
|
| `NextHolidaysOptions` | `{ groupConsecutive?: boolean, types?: HolidayType[], dayOffOnly?: boolean }` |
|