vietnamese-lunar 2.2.1 → 2.3.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 CHANGED
@@ -2,6 +2,12 @@
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.3.0 — 2026-11-26
6
+
7
+ ### Changed
8
+
9
+ - 27/7 is a statutory day off from 2027 (amended Labor Code, passed 21/11/2026) and is named "Ngày Tổ quốc tri ân, Ngày Thương binh, liệt sĩ": `isPublicHoliday` / `isDayOff` are `true` and `type` is `"public"` for 2027 onward, in `dayInfo().holidays`, `getHolidays` and `nextHolidays` (so `dayOffOnly` / `types: ["public"]` now include it). Years 1947–2026 are unchanged ("Ngày Thương binh Liệt sĩ", `commemorative`, not a day off).
10
+
5
11
  ## 2.2.1 — 2026-11-09
6
12
 
7
13
  - `homepage` in package.json and the README now point to the live demo at https://amlich.tandd.dev.
@@ -4,17 +4,24 @@ exports.nextHolidays = exports.getHolidays = exports.getVietnameseHolidays = voi
4
4
  const input_js_1 = require("./input.js");
5
5
  const lunar_js_1 = require("./lunar.js");
6
6
  const utils_js_1 = require("./utils.js");
7
- const typeOf = (def, calendar) => { var _a; return def.isPublicHoliday ? 'public' : (_a = def.type) !== null && _a !== void 0 ? _a : (calendar === 'lunar' ? 'traditional' : 'commemorative'); };
8
- const toHoliday = (def, calendar) => ({
9
- name: def.name,
10
- calendar,
11
- isPublicHoliday: def.isPublicHoliday,
12
- type: typeOf(def, calendar),
13
- isDayOff: def.isPublicHoliday,
14
- });
7
+ const isPublicIn = (def, year) => def.isPublicHoliday || (def.publicSince !== undefined && year >= def.publicSince);
8
+ const toHoliday = (def, calendar, year) => {
9
+ var _a;
10
+ const isPublic = isPublicIn(def, year);
11
+ return {
12
+ name: def.renamed && year >= def.renamed.since ? def.renamed.name : def.name,
13
+ calendar,
14
+ isPublicHoliday: isPublic,
15
+ type: isPublic ? 'public' : (_a = def.type) !== null && _a !== void 0 ? _a : (calendar === 'lunar' ? 'traditional' : 'commemorative'),
16
+ isDayOff: isPublic,
17
+ };
18
+ };
15
19
  const GIAO_THUA = { name: "Giao thừa", isPublicHoliday: false };
16
- // isPublicHoliday: ngày nghỉ hưởng nguyên lương theo Điều 112 Bộ luật Lao động 2019 (sửa đổi bởi Nghị quyết 28/2026/QH16).
20
+ // isPublicHoliday: ngày nghỉ hưởng nguyên lương theo Điều 112 Bộ luật Lao động 2019.
21
+ // 24/11 nghỉ từ 2026 theo Nghị quyết 28/2026/QH16 (hiệu lực 1/7/2026); từ 2027 được ghi vào Điều 112 cùng 27/7
22
+ // (Luật sửa đổi Bộ luật Lao động, thông qua 21/11/2026, hiệu lực 1/3/2027).
17
23
  // since: năm đầu tiên ngày lễ/kỷ niệm tồn tại; không ghi nhận cho các năm trước đó.
24
+ // publicSince: năm đầu tiên ngày kỷ niệm trở thành ngày nghỉ hưởng lương (isPublicHoliday: true từ năm đó).
18
25
  const SOLAR_HOLIDAYS = {
19
26
  "1-1": { name: "Tết Dương lịch", isPublicHoliday: true },
20
27
  "3-2": { name: "Ngày thành lập Đảng Cộng sản Việt Nam", isPublicHoliday: false, since: 1930 },
@@ -27,7 +34,11 @@ const SOLAR_HOLIDAYS = {
27
34
  "19-5": { name: "Ngày sinh Chủ tịch Hồ Chí Minh", isPublicHoliday: false, since: 1890 },
28
35
  "1-6": { name: "Ngày Quốc tế Thiếu nhi", isPublicHoliday: false, since: 1950 },
29
36
  "28-6": { name: "Ngày Gia đình Việt Nam", isPublicHoliday: false, since: 2001 },
30
- "27-7": { name: "Ngày Thương binh Liệt sĩ", isPublicHoliday: false, since: 1947 },
37
+ "27-7": {
38
+ name: "Ngày Thương binh Liệt sĩ", isPublicHoliday: false, since: 1947,
39
+ // Luật sửa đổi Bộ luật Lao động (Quốc hội thông qua 21/11/2026): nghỉ hưởng lương từ 2027.
40
+ publicSince: 2027, renamed: { since: 2027, name: "Ngày Tổ quốc tri ân, Ngày Thương binh, liệt sĩ" },
41
+ },
31
42
  "19-8": { name: "Ngày Cách mạng tháng Tám", isPublicHoliday: false, since: 1945 },
32
43
  "2-9": { name: "Ngày Quốc khánh", isPublicHoliday: true, since: 1945 },
33
44
  "10-10": { name: "Ngày Giải phóng Thủ đô", isPublicHoliday: false, since: 1954 },
@@ -58,26 +69,27 @@ const getVietnameseHolidays = (solarDay, solarMonth, solarYear, lunarDate, nextL
58
69
  const holidays = [];
59
70
  const solarHoliday = SOLAR_HOLIDAYS[`${solarDay}-${solarMonth}`];
60
71
  if (solarHoliday && (solarHoliday.since === undefined || solarYear >= solarHoliday.since)) {
61
- holidays.push(toHoliday(solarHoliday, 'solar'));
72
+ holidays.push(toHoliday(solarHoliday, 'solar', solarYear));
62
73
  }
63
74
  // Lễ âm lịch chỉ tính cho tháng thường, tránh lặp lại ở tháng nhuận.
64
75
  if (lunarDate.date !== 0 && !lunarDate.isLeap) {
65
76
  const lunarHoliday = LUNAR_HOLIDAYS[`${lunarDate.date}-${lunarDate.month}`];
66
77
  if (lunarHoliday) {
67
- holidays.push(toHoliday(lunarHoliday, 'lunar'));
78
+ holidays.push(toHoliday(lunarHoliday, 'lunar', solarYear));
68
79
  }
69
80
  }
70
81
  // Tháng Chạp có thể có 29 hoặc 30 ngày, nên Giao thừa là ngày ngay trước mùng 1 Tết.
71
82
  if (nextLunarDate.date === 1 && nextLunarDate.month === 1 && !nextLunarDate.isLeap) {
72
- holidays.push(toHoliday(GIAO_THUA, 'lunar'));
83
+ holidays.push(toHoliday(GIAO_THUA, 'lunar', solarYear));
73
84
  }
74
85
  return holidays;
75
86
  };
76
87
  exports.getVietnameseHolidays = getVietnameseHolidays;
77
88
  const eventOf = (def, calendar, jd, lunar) => {
78
- const h = toHoliday(def, calendar);
89
+ const date = (0, utils_js_1.jdToSolarDate)(jd);
90
+ const h = toHoliday(def, calendar, date.year);
79
91
  const event = {
80
- name: h.name, date: (0, utils_js_1.jdToSolarDate)(jd), calendar, type: h.type, isDayOff: h.isDayOff, isPublicHoliday: h.isPublicHoliday,
92
+ name: h.name, date, calendar, type: h.type, isDayOff: h.isDayOff, isPublicHoliday: h.isPublicHoliday,
81
93
  };
82
94
  if (lunar)
83
95
  event.lunarDate = lunar;
@@ -1,17 +1,24 @@
1
1
  import { requireDateInput } from "./input.js";
2
2
  import { getLunarDate, getSolarDate } from "./lunar.js";
3
3
  import { jdToSolarDate, getJulianDayNumber } from "./utils.js";
4
- const typeOf = (def, calendar) => { var _a; return def.isPublicHoliday ? 'public' : (_a = def.type) !== null && _a !== void 0 ? _a : (calendar === 'lunar' ? 'traditional' : 'commemorative'); };
5
- const toHoliday = (def, calendar) => ({
6
- name: def.name,
7
- calendar,
8
- isPublicHoliday: def.isPublicHoliday,
9
- type: typeOf(def, calendar),
10
- isDayOff: def.isPublicHoliday,
11
- });
4
+ const isPublicIn = (def, year) => def.isPublicHoliday || (def.publicSince !== undefined && year >= def.publicSince);
5
+ const toHoliday = (def, calendar, year) => {
6
+ var _a;
7
+ const isPublic = isPublicIn(def, year);
8
+ return {
9
+ name: def.renamed && year >= def.renamed.since ? def.renamed.name : def.name,
10
+ calendar,
11
+ isPublicHoliday: isPublic,
12
+ type: isPublic ? 'public' : (_a = def.type) !== null && _a !== void 0 ? _a : (calendar === 'lunar' ? 'traditional' : 'commemorative'),
13
+ isDayOff: isPublic,
14
+ };
15
+ };
12
16
  const GIAO_THUA = { name: "Giao thừa", isPublicHoliday: false };
13
- // isPublicHoliday: ngày nghỉ hưởng nguyên lương theo Điều 112 Bộ luật Lao động 2019 (sửa đổi bởi Nghị quyết 28/2026/QH16).
17
+ // isPublicHoliday: ngày nghỉ hưởng nguyên lương theo Điều 112 Bộ luật Lao động 2019.
18
+ // 24/11 nghỉ từ 2026 theo Nghị quyết 28/2026/QH16 (hiệu lực 1/7/2026); từ 2027 được ghi vào Điều 112 cùng 27/7
19
+ // (Luật sửa đổi Bộ luật Lao động, thông qua 21/11/2026, hiệu lực 1/3/2027).
14
20
  // since: năm đầu tiên ngày lễ/kỷ niệm tồn tại; không ghi nhận cho các năm trước đó.
21
+ // publicSince: năm đầu tiên ngày kỷ niệm trở thành ngày nghỉ hưởng lương (isPublicHoliday: true từ năm đó).
15
22
  const SOLAR_HOLIDAYS = {
16
23
  "1-1": { name: "Tết Dương lịch", isPublicHoliday: true },
17
24
  "3-2": { name: "Ngày thành lập Đảng Cộng sản Việt Nam", isPublicHoliday: false, since: 1930 },
@@ -24,7 +31,11 @@ const SOLAR_HOLIDAYS = {
24
31
  "19-5": { name: "Ngày sinh Chủ tịch Hồ Chí Minh", isPublicHoliday: false, since: 1890 },
25
32
  "1-6": { name: "Ngày Quốc tế Thiếu nhi", isPublicHoliday: false, since: 1950 },
26
33
  "28-6": { name: "Ngày Gia đình Việt Nam", isPublicHoliday: false, since: 2001 },
27
- "27-7": { name: "Ngày Thương binh Liệt sĩ", isPublicHoliday: false, since: 1947 },
34
+ "27-7": {
35
+ name: "Ngày Thương binh Liệt sĩ", isPublicHoliday: false, since: 1947,
36
+ // Luật sửa đổi Bộ luật Lao động (Quốc hội thông qua 21/11/2026): nghỉ hưởng lương từ 2027.
37
+ publicSince: 2027, renamed: { since: 2027, name: "Ngày Tổ quốc tri ân, Ngày Thương binh, liệt sĩ" },
38
+ },
28
39
  "19-8": { name: "Ngày Cách mạng tháng Tám", isPublicHoliday: false, since: 1945 },
29
40
  "2-9": { name: "Ngày Quốc khánh", isPublicHoliday: true, since: 1945 },
30
41
  "10-10": { name: "Ngày Giải phóng Thủ đô", isPublicHoliday: false, since: 1954 },
@@ -55,25 +66,26 @@ export const getVietnameseHolidays = (solarDay, solarMonth, solarYear, lunarDate
55
66
  const holidays = [];
56
67
  const solarHoliday = SOLAR_HOLIDAYS[`${solarDay}-${solarMonth}`];
57
68
  if (solarHoliday && (solarHoliday.since === undefined || solarYear >= solarHoliday.since)) {
58
- holidays.push(toHoliday(solarHoliday, 'solar'));
69
+ holidays.push(toHoliday(solarHoliday, 'solar', solarYear));
59
70
  }
60
71
  // Lễ âm lịch chỉ tính cho tháng thường, tránh lặp lại ở tháng nhuận.
61
72
  if (lunarDate.date !== 0 && !lunarDate.isLeap) {
62
73
  const lunarHoliday = LUNAR_HOLIDAYS[`${lunarDate.date}-${lunarDate.month}`];
63
74
  if (lunarHoliday) {
64
- holidays.push(toHoliday(lunarHoliday, 'lunar'));
75
+ holidays.push(toHoliday(lunarHoliday, 'lunar', solarYear));
65
76
  }
66
77
  }
67
78
  // Tháng Chạp có thể có 29 hoặc 30 ngày, nên Giao thừa là ngày ngay trước mùng 1 Tết.
68
79
  if (nextLunarDate.date === 1 && nextLunarDate.month === 1 && !nextLunarDate.isLeap) {
69
- holidays.push(toHoliday(GIAO_THUA, 'lunar'));
80
+ holidays.push(toHoliday(GIAO_THUA, 'lunar', solarYear));
70
81
  }
71
82
  return holidays;
72
83
  };
73
84
  const eventOf = (def, calendar, jd, lunar) => {
74
- const h = toHoliday(def, calendar);
85
+ const date = jdToSolarDate(jd);
86
+ const h = toHoliday(def, calendar, date.year);
75
87
  const event = {
76
- name: h.name, date: jdToSolarDate(jd), calendar, type: h.type, isDayOff: h.isDayOff, isPublicHoliday: h.isPublicHoliday,
88
+ name: h.name, date, calendar, type: h.type, isDayOff: h.isDayOff, isPublicHoliday: h.isPublicHoliday,
77
89
  };
78
90
  if (lunar)
79
91
  event.lunarDate = lunar;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vietnamese-lunar",
3
- "version": "2.2.1",
3
+ "version": "2.3.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
@@ -199,7 +199,11 @@ Items of `getHolidays()` / `nextHolidays()` are *events*, not the `holidays[]` e
199
199
 
200
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".
201
201
 
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.
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). 27/7 is a statutory day off from 2027 under the name "Ngày Tổ quốc tri ân, Ngày Thương binh, liệt sĩ" (`isPublicHoliday: true`, `type: "public"`); earlier years report it as "Ngày Thương binh Liệt sĩ", `commemorative`. `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.
203
+
204
+ ## 🆕 New in 2.3.0
205
+
206
+ - **27/7 is a day off from 2027.** It is reported as "Ngày Tổ quốc tri ân, Ngày Thương binh, liệt sĩ" with `isPublicHoliday: true`, `isDayOff: true`, `type: "public"`, so `nextHolidays(..., {dayOffOnly: true})` and `{types: ["public"]}` include it. Before 2027 it stays "Ngày Thương binh Liệt sĩ" (`commemorative`). No API changes.
203
207
 
204
208
  ## 🆕 New in 2.2.0
205
209