vietnamese-lunar 2.1.1 → 2.2.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/CHANGELOG.md CHANGED
@@ -2,6 +2,25 @@
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.1 — 2026-11-09
6
+
7
+ - `homepage` in package.json and the README now point to the live demo at https://amlich.tandd.dev.
8
+
9
+ ## 2.2.0 — 2026-11-01
10
+
11
+ Backward compatible with 2.1.1: the default behaviour and every existing field are unchanged.
12
+
13
+ ### Added
14
+
15
+ - `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?)`.
16
+ - `dayStar.monthBasis`: the basis used for that result (new field, always present).
17
+ - New exported type `MonthBasis`; `DayInfoOptions` gains `monthBasis`.
18
+ - 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).
19
+
20
+ ### Notes
21
+
22
+ - `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.
23
+
5
24
  ## 2.1.1 — 2026-11-01
6
25
 
7
26
  ### ⚠️ Behaviour changes (relative to 2.1.0)
@@ -46,7 +65,7 @@ Checked by running 2.1.0 and this version side by side on 20,863 dates (every 7t
46
65
 
47
66
  ### Not in this release
48
67
 
49
- - `monthBasis: 'solar-term' | 'lunar-month'` for `dayStar` (optional item C of the request) — deferred to 2.2.0.
68
+ - `monthBasis` for `dayStar` — shipped in 2.2.0.
50
69
 
51
70
  ## 2.1.0 — 2026-11-01
52
71
 
@@ -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 {};
@@ -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 = (julianDay) => {
39
- const thanhLongChiIndex = THANH_LONG_OFFSET_BY_MONTH_ZHI[(0, heavenly_earthly_js_1.getMonthBranchIndex)(julianDay)];
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.julianDay);
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
  };
@@ -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;
@@ -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 {};
@@ -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 = (julianDay) => {
35
- const thanhLongChiIndex = THANH_LONG_OFFSET_BY_MONTH_ZHI[getMonthBranchIndex(julianDay)];
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.julianDay);
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
  };
@@ -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.1.1",
3
+ "version": "2.2.1",
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",
@@ -80,7 +80,7 @@
80
80
  "bugs": {
81
81
  "url": "https://gitlab.com/tandd.packages/vietnamese-lunar-calendar/issues"
82
82
  },
83
- "homepage": "https://gitlab.com/tandd.packages/vietnamese-lunar-calendar#readme",
83
+ "homepage": "https://amlich.tandd.dev",
84
84
  "dependencies": {},
85
85
  "devDependencies": {
86
86
  "typescript": "^5.9.3"
package/readme.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  A lightweight JavaScript utility to convert Gregorian (solar) dates to traditional lunar calendar dates — perfect for apps with cultural, astrological, or calendrical features.
4
4
 
5
+ 🔗 **Live demo:** [amlich.tandd.dev](https://amlich.tandd.dev)
6
+
5
7
  ---
6
8
 
7
9
  ## ✨ Features
@@ -85,6 +87,7 @@ outputs:
85
87
  index: 4,
86
88
  category: "hac-dao",
87
89
  system: "hiep-ky",
90
+ monthBasis: "solar-term",
88
91
  aliases: []
89
92
  },
90
93
  holidays: [],
@@ -170,6 +173,7 @@ Fields of `dayInfo()`. Fields marked *(2.1.0)* / *(2.1.1)* were added in that ve
170
173
  | dayStar.star | name of the day star (e.g. Thanh Long, Bạch Hổ) |
171
174
  | dayStar.isAuspicious | kept for 2.x: true iff `category === "hoang-dao"`. **`false` does not mean hắc đạo** — see `category` |
172
175
  | dayStar.index / category / system / aliases | *(2.1.0)* 1..12 (Thanh Long = 1), `"hoang-dao" \| "hac-dao" \| null`, `"hiep-ky" \| "ngoc-hap"`, alternative names |
176
+ | dayStar.monthBasis | *(2.2.0)* how the month branch (Nguyệt Kiến) was determined: `"solar-term"` (default) or `"lunar-month"` |
173
177
  | solarTerm | *(2.1.0)* `{current, next}` |
174
178
  | solarTerm.current / next | `{name, index, start, startLocal}`; `next` also has `daysUntil` |
175
179
  | solarTerm.*.index | position in `SOLAR_TERMS` (0 = Xuân Phân) |
@@ -193,10 +197,56 @@ Fields of `dayInfo()`. Fields marked *(2.1.0)* / *(2.1.1)* were added in that ve
193
197
 
194
198
  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
199
 
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ư). Some popular Vietnamese almanac sites instead key the month-branch off the lunar calendar month number, which can disagree with this result for up to ~15 days around each solar-term boundary.
200
+ > **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
201
 
198
202
  > **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
203
 
204
+ ## 🆕 New in 2.2.0
205
+
206
+ ### `monthBasis` for `dayStar`
207
+
208
+ `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.
209
+
210
+ | | `solar-term` (default) | `lunar-month` |
211
+ |---|---|---|
212
+ | 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 … |
213
+ | Leap month | not applicable (follows the sun) | same branch as the regular month with the same number |
214
+ | Source | classical rule; same as `solarTerms` | what many Vietnamese almanac websites show |
215
+ | 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 |
216
+
217
+ 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.
218
+
219
+ <!-- example:month-basis -->
220
+ | Solar date | Lunar | `solar-term` (default): month branch → day star | `lunar-month`: month branch → day star |
221
+ |---|---|---|---|
222
+ | 1/1/2025 | 2/12 | tháng Tý → Tư Mệnh (hoang-dao) | tháng Sửu → Thiên Lao (hac-dao) |
223
+ | 4/1/2025 | 5/12 | tháng Tý → Minh Đường (hoang-dao) | tháng Sửu → Câu Trận (hac-dao) |
224
+ | 30/1/2025 | 2/1 | tháng Sửu → Minh Đường (hoang-dao) | tháng Dần → Câu Trận (hac-dao) |
225
+ | 17/10/2025 | 26/8 | tháng Tuất → Chu Tước (hac-dao) | tháng Dậu → Thiên Đức (hoang-dao) |
226
+
227
+ In 2025 the two bases give a different day star on **118 of 365 days**.
228
+ <!-- /example -->
229
+
230
+ <!-- example:month-basis-usage -->
231
+ ```javascript
232
+ dayInfo("1/1/2025", {monthBasis: "lunar-month"}).dayStar
233
+ // → {
234
+ // star: "Thiên Lao",
235
+ // isAuspicious: false,
236
+ // index: 9,
237
+ // category: "hac-dao",
238
+ // system: "hiep-ky",
239
+ // monthBasis: "lunar-month",
240
+ // aliases: []
241
+ // }
242
+
243
+ getDayStarInfo(getLunarDate(1, 1, 2025), "hiep-ky", "lunar-month").monthBasis
244
+ // → "lunar-month"
245
+ ```
246
+ <!-- /example -->
247
+
248
+ `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.)*
249
+
200
250
  ## 🆕 New in 2.1.1
201
251
 
202
252
  Fixes and clarifications on top of 2.1.0 (the first three bullets change behaviour — see [CHANGELOG.md](CHANGELOG.md)):
@@ -225,6 +275,7 @@ dayInfo("17/10/2025", {starSystem: "ngoc-hap"}).dayStar
225
275
  // index: 4,
226
276
  // category: "hac-dao",
227
277
  // system: "ngoc-hap",
278
+ // monthBasis: "solar-term",
228
279
  // aliases: []
229
280
  // }
230
281
  ```
@@ -450,7 +501,7 @@ Item 10 of the upgrade request (12 Trực, 28 Sao, ngày kỵ, `rating`) is inte
450
501
 
451
502
  ```html
452
503
  <script type="module">
453
- import {dayInfo} from "https://cdn.jsdelivr.net/npm/vietnamese-lunar@2.1.1/lib/esm/index.js";
504
+ import {dayInfo} from "https://cdn.jsdelivr.net/npm/vietnamese-lunar@2.2.0/lib/esm/index.js";
454
505
  </script>
455
506
  ```
456
507
 
@@ -568,7 +619,7 @@ SOLAR_TERMS[getSolarTermIndex(jd)]; // "Hàn Lộ"
568
619
 
569
620
  > `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
621
 
571
- **`getDayStarInfo(lunar: LunarDate, system?: "hiep-ky" | "ngoc-hap"): DayStarInfo`** — 12-star Hoàng Đạo / Hắc Đạo. `system` defaults to `"hiep-ky"`.
622
+ **`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
623
 
573
624
  <!-- example:low-getDayStarInfo -->
574
625
  ```javascript
@@ -579,6 +630,7 @@ getDayStarInfo(getLunarDate(17, 10, 2025)) // default system: "hiep-k
579
630
  // index: 4,
580
631
  // category: "hac-dao",
581
632
  // system: "hiep-ky",
633
+ // monthBasis: "solar-term",
582
634
  // aliases: []
583
635
  // }
584
636
 
@@ -589,8 +641,20 @@ getDayStarInfo(getLunarDate(17, 10, 2025), "ngoc-hap")
589
641
  // index: 4,
590
642
  // category: "hac-dao",
591
643
  // system: "ngoc-hap",
644
+ // monthBasis: "solar-term",
592
645
  // aliases: []
593
646
  // }
647
+
648
+ getDayStarInfo(getLunarDate(17, 10, 2025), "hiep-ky", "lunar-month")
649
+ // → {
650
+ // star: "Thiên Đức",
651
+ // isAuspicious: true,
652
+ // index: 6,
653
+ // category: "hoang-dao",
654
+ // system: "hiep-ky",
655
+ // monthBasis: "lunar-month",
656
+ // aliases: [ "Bảo Quang", "Kim Đường" ]
657
+ // }
594
658
  ```
595
659
  <!-- /example -->
596
660
 
@@ -604,17 +668,18 @@ The lists of hoàng đạo / hắc đạo stars for each system are in the table
604
668
  import type {
605
669
  DayInfo, LunarDayInfo, LunarDate, DayStarInfo, Holiday, dateFormat,
606
670
  DateInput, DayInfoOptions, HourInfo, SolarTermItem, SolarTermInfo, CanChiInfo,
607
- HolidayEvent, NextHolidaysOptions, StarSystem, StarCategory, HolidayType, LocalDateTime,
671
+ HolidayEvent, NextHolidaysOptions, StarSystem, StarCategory, MonthBasis, HolidayType, LocalDateTime,
608
672
  } from "vietnamese-lunar";
609
673
  ```
610
674
 
611
675
  | Type | Shape |
612
676
  |---|---|
613
677
  | `DateInput` | `string \| Date \| {day, month, year}` |
614
- | `DayInfoOptions` | `{ starSystem?: "hiep-ky" \| "ngoc-hap" }` |
678
+ | `DayInfoOptions` | `{ starSystem?: "hiep-ky" \| "ngoc-hap", monthBasis?: "solar-term" \| "lunar-month" }` |
679
+ | `MonthBasis` | `"solar-term" \| "lunar-month"` |
615
680
  | `LunarDate` | `{ date, month, year, isLeap, julianDay, monthDays }` |
616
681
  | `dateFormat` | `{ date, month, year }` — ganzhi names |
617
- | `DayStarInfo` | `{ star, isAuspicious, index, category, system, aliases }` |
682
+ | `DayStarInfo` | `{ star, isAuspicious, index, category, system, monthBasis, aliases }` |
618
683
  | `Holiday` | one entry of `dayInfo().holidays`: `{ name, calendar, isPublicHoliday, type, isDayOff }` |
619
684
  | `HolidayEvent` | item of `getHolidays` / `nextHolidays`: `{ name, date, calendar, lunarDate?, type, isDayOff, isPublicHoliday, endDate?, days? }` |
620
685
  | `NextHolidaysOptions` | `{ groupConsecutive?: boolean, types?: HolidayType[], dayOffOnly?: boolean }` |