Skip to content

Commit

Permalink
🛠️ upgrade decadal setup rule to make it consistent with configurat…
Browse files Browse the repository at this point in the history
…ion.
  • Loading branch information
SylarLong committed Apr 30, 2024
1 parent a10b1af commit 214bab2
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 3 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@
- 🛠️ 修复(fix)
- 🧹 琐事(Chore)

## v2.4.2

- 🛠️ 修复(fix)

🇨🇳

- 更新起大限的规则,使它与全局配置同步

🇺🇸

- upgrade `decadal` setup rule to make it consistent with configuration.

## v2.4.1

- ✨ 改进(enhancement)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
23 changes: 23 additions & 0 deletions src/__tests__/astro/astro.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
4 changes: 2 additions & 2 deletions src/astro/palace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ export const getHoroscope = (
const decadals: Decadal[] = [];
const genderKey = kot<GenderKey>(gender);
const { yearly } = getHeavenlyStemAndEarthlyBranchBySolarDate(solarDateStr, timeIndex, {
// 运限是以立春为界
year: 'exact',
// 起大限应该与配置同步
year: getConfig().yearDivide,
});
const heavenlyStem = kot<HeavenlyStemKey>(yearly[0], 'Heavenly');
const earthlyBranch = kot<EarthlyBranchKey>(yearly[1], 'Earthly');
Expand Down

0 comments on commit 214bab2

Please sign in to comment.