@openfate/bazi-engine 1.1.0 → 1.1.2
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/dist/index.js +25 -7
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -92,7 +92,7 @@ function createLunarDateTime(solarDateTime) {
|
|
|
92
92
|
* ```
|
|
93
93
|
*/
|
|
94
94
|
function calculateBaziChart(input) {
|
|
95
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
95
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
96
96
|
(0, validation_1.validateBaziInput)(input);
|
|
97
97
|
let solarYear = input.year;
|
|
98
98
|
let solarMonth = input.month;
|
|
@@ -158,8 +158,26 @@ function calculateBaziChart(input) {
|
|
|
158
158
|
algorithm: detail.algorithm,
|
|
159
159
|
};
|
|
160
160
|
}
|
|
161
|
+
else if (((_e = input.dstOffset) !== null && _e !== void 0 ? _e : 0) !== 0 && input.hour !== undefined) {
|
|
162
|
+
// ── 2b. DST normalization without True Solar Time ────────────────────
|
|
163
|
+
// DST is a civil-clock correction, not a solar-time refinement: a birth
|
|
164
|
+
// recorded at 15:20 during a DST period (e.g. China 1986–1991 summer,
|
|
165
|
+
// Taiwan 1946–1961) actually occurred at 14:20 standard time. The TST
|
|
166
|
+
// path above already subtracts dstOffset inside calculateTrueSolarTime;
|
|
167
|
+
// when TST is disabled it must still be normalized out here, otherwise
|
|
168
|
+
// the pillars use the shifted clock hour — a wrong 时辰, and near
|
|
169
|
+
// midnight a wrong day pillar. Date-based math keeps day/month/year
|
|
170
|
+
// rollover safe (lunar input was already converted to solar above).
|
|
171
|
+
const shifted = new Date(Date.UTC(solarYear, solarMonth - 1, solarDay, solarHour, solarMinute));
|
|
172
|
+
shifted.setUTCMinutes(shifted.getUTCMinutes() - Math.round(((_f = input.dstOffset) !== null && _f !== void 0 ? _f : 0) * 60));
|
|
173
|
+
solarYear = shifted.getUTCFullYear();
|
|
174
|
+
solarMonth = shifted.getUTCMonth() + 1;
|
|
175
|
+
solarDay = shifted.getUTCDate();
|
|
176
|
+
solarHour = shifted.getUTCHours();
|
|
177
|
+
solarMinute = shifted.getUTCMinutes();
|
|
178
|
+
}
|
|
161
179
|
// ── 3. Generate Four Pillars ─────────────────────────────────────────────
|
|
162
|
-
const { pillars, eightChar, dayStem } = (0, pillars_1.generatePillarsFromSolar)(solarYear, solarMonth, solarDay, solarHour, solarMinute, solarSecond, (
|
|
180
|
+
const { pillars, eightChar, dayStem } = (0, pillars_1.generatePillarsFromSolar)(solarYear, solarMonth, solarDay, solarHour, solarMinute, solarSecond, (_g = input.dayBoundaryMode) !== null && _g !== void 0 ? _g : 'MIDNIGHT_00');
|
|
163
181
|
// ── 4. Day Master ────────────────────────────────────────────────────────
|
|
164
182
|
const dayMaster = (0, pillars_1.getStemInfo)(dayStem);
|
|
165
183
|
// ── 5. Da Yun Cycles ─────────────────────────────────────────────────────
|
|
@@ -169,7 +187,7 @@ function calculateBaziChart(input) {
|
|
|
169
187
|
year: pillars.year.branch,
|
|
170
188
|
month: pillars.month.branch,
|
|
171
189
|
day: pillars.day.branch,
|
|
172
|
-
hour: (
|
|
190
|
+
hour: (_j = (_h = pillars.hour) === null || _h === void 0 ? void 0 : _h.branch) !== null && _j !== void 0 ? _j : '',
|
|
173
191
|
});
|
|
174
192
|
const calculationSolar = createDateTime(solarYear, solarMonth, solarDay, input.hour === undefined ? undefined : solarHour, input.hour === undefined ? undefined : solarMinute, input.hour === undefined ? undefined : solarSecond);
|
|
175
193
|
const lunarCalendar = createLunarDateTime(calculationSolar);
|
|
@@ -188,10 +206,10 @@ function calculateBaziChart(input) {
|
|
|
188
206
|
},
|
|
189
207
|
metadata: {
|
|
190
208
|
trueSolarTimeApplied: enableTST,
|
|
191
|
-
dayBoundaryMode: (
|
|
192
|
-
longitude: (
|
|
193
|
-
timezoneBasis: (
|
|
194
|
-
dstOffset: (
|
|
209
|
+
dayBoundaryMode: (_k = input.dayBoundaryMode) !== null && _k !== void 0 ? _k : 'MIDNIGHT_00',
|
|
210
|
+
longitude: (_l = input.longitude) !== null && _l !== void 0 ? _l : null,
|
|
211
|
+
timezoneBasis: (_o = (_m = input.timezone) !== null && _m !== void 0 ? _m : input.timezoneId) !== null && _o !== void 0 ? _o : null,
|
|
212
|
+
dstOffset: (_p = input.dstOffset) !== null && _p !== void 0 ? _p : 0,
|
|
195
213
|
},
|
|
196
214
|
};
|
|
197
215
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openfate/bazi-engine",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "Accurate Four Pillars (八字) chart engine with True Solar Time correction, Da Yun cycles, and interaction detection. Extracted from the OpenFate.ai core engine.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"scripts": {
|
|
13
13
|
"build": "tsc",
|
|
14
14
|
"test": "node --import tsx --test tests/*.test.ts",
|
|
15
|
-
"release": "npm version patch && git push --follow-tags",
|
|
15
|
+
"release": "npm version patch -m \"chore: release v%s [release]\" && git push --follow-tags",
|
|
16
16
|
"prepublishOnly": "npm run build && npm run test"
|
|
17
17
|
},
|
|
18
18
|
"author": {
|