From 214bab2448208588b6e260e695a92772bc2a71db Mon Sep 17 00:00:00 2001 From: Sylar Date: Tue, 30 Apr 2024 23:04:53 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=9B=A0=EF=B8=8F=20upgrade=20`decadal`=20s?= =?UTF-8?q?etup=20rule=20to=20make=20it=20consistent=20with=20configuratio?= =?UTF-8?q?n.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 12 ++++++++++++ package.json | 2 +- src/__tests__/astro/astro.test.ts | 23 +++++++++++++++++++++++ src/astro/palace.ts | 4 ++-- 4 files changed, 38 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1499cce..c28e8d7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,18 @@ - 🛠️ 修复(fix) - 🧹 琐事(Chore) +## v2.4.2 + +- 🛠️ 修复(fix) + + 🇨🇳 + + - 更新起大限的规则,使它与全局配置同步 + + 🇺🇸 + + - upgrade `decadal` setup rule to make it consistent with configuration. + ## v2.4.1 - ✨ 改进(enhancement) diff --git a/package.json b/package.json index 44f11ef..dc8ff00 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "iztro", - "version": "2.4.1", + "version": "2.4.2", "description": "轻量级紫微斗数星盘生成库。可以通过出生年月日获取到紫微斗数星盘信息、生肖、星座等信息。A lightweight kit to astrolabe generator of The Purple Star Astrology (Zi Wei Dou Shu). The Purple Star Astrology(Zi Wei Dou Shu) is a Chinese ancient astrology. You're able to get your horoscope and personality from the astrolabe", "main": "lib/index.js", "types": "lib/index.d.ts", diff --git a/src/__tests__/astro/astro.test.ts b/src/__tests__/astro/astro.test.ts index 7c47cdf..d1d8225 100644 --- a/src/__tests__/astro/astro.test.ts +++ b/src/__tests__/astro/astro.test.ts @@ -625,6 +625,29 @@ describe('Astrolabe', () => { expect(result).toHaveProperty('fiveElementsClass', '火六局'); }); + test('bySolar() with `normal` year divider', () => { + astro.config({ yearDivide: 'normal' }); + + const result = astro.bySolar('1980-2-14', 0, 'male', true); + + expect(result).toHaveProperty('solarDate', '1980-2-14'); + expect(result).toHaveProperty('lunarDate', '一九七九年腊月廿八'); + expect(result).toHaveProperty('chineseDate', '己未 戊寅 丁巳 庚子'); + expect(result).toHaveProperty('time', '早子时'); + expect(result).toHaveProperty('zodiac', '羊'); + expect(result).toHaveProperty('earthlyBranchOfSoulPalace', '丑'); + expect(result).toHaveProperty('earthlyBranchOfBodyPalace', '丑'); + expect(result).toHaveProperty('soul', '巨门'); + expect(result).toHaveProperty('body', '天相'); + expect(result).toHaveProperty('fiveElementsClass', '水二局'); + + expect(result.palaces[0].decadal).toHaveProperty('range', [112, 121]); + const horoscope = result.horoscope('1980-2-14'); + + expect(horoscope.yearly).toHaveProperty('earthlyBranch', '申'); + expect(horoscope.yearly).toHaveProperty('heavenlyStem', '庚'); + }); + test('withOptions()', () => { const result = astro.withOptions({ type: 'lunar', diff --git a/src/astro/palace.ts b/src/astro/palace.ts index 248bc22..73d700d 100644 --- a/src/astro/palace.ts +++ b/src/astro/palace.ts @@ -184,8 +184,8 @@ export const getHoroscope = ( const decadals: Decadal[] = []; const genderKey = kot(gender); const { yearly } = getHeavenlyStemAndEarthlyBranchBySolarDate(solarDateStr, timeIndex, { - // 运限是以立春为界 - year: 'exact', + // 起大限应该与配置同步 + year: getConfig().yearDivide, }); const heavenlyStem = kot(yearly[0], 'Heavenly'); const earthlyBranch = kot(yearly[1], 'Earthly');