星盘
概述
紫微斗数星盘又叫紫微斗数命盘,是由 十二个宫位 和一个 中宫 构成,宫位的 地支 是固定的,并且是由 寅 开始,而不是由 子 开始。这是因为农历的正月是寅月,这就是所谓的 正月建寅。在 iztro 里面,寅宫 的索引是 0,卯宫 的索引是 1,如此按照顺时针的方向排列。如下面表格所示:
巳 3 | 午 4 | 未 5 | 申 6 |
辰 2 | 中宫 | 酉 7 | |
卯 1 | 戌 8 | ||
寅 0 | 丑 11 | 子 10 | 亥 9 |
中宫 通常可以用来展示任何你想展示的信息,一般不会对整个星盘产生影响。周围的 十二宫 用于存放星耀,四化,运限,宫位名称等信息。关于 宫位 的详细信息,可以进入 宫位传送门 查看详细介绍,本页面主要关注星盘的信息。紫微斗数星盘是由宫位和星耀组成的,如果你还没有建立起它们的概念,我们强烈推荐你进入 传送门 开始学习有趣的紫微斗数知识。
在安装好 iztro 依赖以后你可以用如下代码将 星盘(astro) 对象引入你的代码。如果你还不知道如何安装 iztro,请点击 传送门 跳转到相关说明文档。
astro 的静态方法
要使用该对象的静态方法,请先将该对象 import 到你的代码里
import { astro } from "iztro";import { astro } from "iztro";astrolabeBySolarDate
用途
通过阳历获取星盘信息
定义
tsexport type astrolabeBySolarDate = ( solarDateStr: string, timeIndex: number, gender: GenderName, fixLeap: boolean = true, language: Language = "zh-CN" ) => FunctionalAstrolabe;export type astrolabeBySolarDate = ( solarDateStr: string, timeIndex: number, gender: GenderName, fixLeap: boolean = true, language: Language = "zh-CN" ) => FunctionalAstrolabe;参数
参数 类型 是否必填 默认值 说明 solarDateStr stringtrue- 阳历日期【YYYY-M-D】 timeIndex numbertrue- 出生时辰序号【0~12】,对应从早子时(0)一直到晚子时(12)的序号 gender GenderNametrue- 性别【男/女】 fixLeap booleanfalsetrue是否调整闰月,为 true闰月的前半个月算上个月,后半个月算下个月language Languagefalsezh-CN返回数据将被国际化为指定语言。目前支持 zh-CN,zh-TW,en-US,ko-KR和ja-JP返回值
示例
tsimport { astro } from "iztro"; const astrolabe = astro.astrolabeBySolarDate("2000-8-16", 2, "女", true, "zh-CN");import { astro } from "iztro"; const astrolabe = astro.astrolabeBySolarDate("2000-8-16", 2, "女", true, "zh-CN");示例返回值
返回值
ts{ // 阳历日期 solarDate: '2000-8-16', // 农历日期 lunarDate: '二〇〇〇年七月十七', // 四柱 chineseDate: '庚辰 甲申 丙午 庚寅', // 时辰 time: '寅时', // 时辰对应的时间段 timeRange: '03:00~05:00', // 星座 sign: '狮子座', // 生肖 zodiac: '龙', // 命宫地支 earthlyBranchOfSoulPalace: '午', // 身宫地支 earthlyBranchOfBodyPalace: '戌', // 命主 soul: '破军', // 身主 body: '文昌', // 五行局 fiveElementsClass: '木三局', // 十二宫数据 palaces: [ { // 宫名 name: '财帛', // 是否身宫 isBodyPalace: false, // 是否来因宫 isOriginalPalace: false, // 宫位天干 heavenlyStem: '戊', // 宫位地支 earthlyBranch: '寅', // 主星(含天马禄存) majorStars: [ { name: '武曲', type: 'major', scope: 'origin', brightness: '得' }, { name: '天相', type: 'major', scope: 'origin', brightness: '庙' }, { name: '天马', type: 'tianma', scope: 'origin', brightness: '' }, ], // 辅星(含六吉六煞) minorStars: [], // 杂耀 adjectiveStars: [ { name: '月解', type: 'helper', scope: 'origin' }, { name: '三台', type: 'adjective', scope: 'origin' }, { name: '天寿', type: 'adjective', scope: 'origin' }, { name: '天巫', type: 'adjective', scope: 'origin' }, { name: '天厨', type: 'adjective', scope: 'origin' }, { name: '阴煞', type: 'adjective', scope: 'origin' }, { name: '天哭', type: 'adjective', scope: 'origin' }, ], // 长生12神 changsheng12: '绝', // 博士12神 boshi12: '蜚廉', // 流年将前12神 jiangqian12: '岁驿', // 流年岁前12神 suiqian12: '吊客', // 大限 stage: { range: [44, 53], heavenlyStem: '戊' }, // 小限 ages: [9, 21, 33, 45, 57, 69, 81], }, { name: '子女', isBodyPalace: false, isOriginalPalace: false, heavenlyStem: '己', earthlyBranch: '卯', majorStars: [ { name: '太阳', type: 'major', scope: 'origin', brightness: '庙' }, { name: '天梁', type: 'major', scope: 'origin', brightness: '庙' }, ], minorStars: [], adjectiveStars: [{ name: '天刑', type: 'adjective', scope: 'origin' }], changsheng12: '墓', boshi12: '奏书', jiangqian12: '息神', suiqian12: '病符', stage: { range: [34, 43], heavenlyStem: '己' }, ages: [8, 20, 32, 44, 56, 68, 80], }, { name: '夫妻', isBodyPalace: false, isOriginalPalace: true, heavenlyStem: '庚', earthlyBranch: '辰', majorStars: [{ name: '七杀', type: 'major', scope: 'origin', brightness: '庙' }], minorStars: [ { name: '右弼', type: 'soft', scope: 'origin', brightness: '' }, { name: '火星', type: 'tough', scope: 'origin', brightness: '陷' }, ], adjectiveStars: [ { name: '封诰', type: 'adjective', scope: 'origin' }, { name: '华盖', type: 'adjective', scope: 'origin' }, ], changsheng12: '死', boshi12: '将军', jiangqian12: '华盖', suiqian12: '岁建', stage: { range: [24, 33], heavenlyStem: '庚' }, ages: [7, 19, 31, 43, 55, 67, 79], }, { name: '兄弟', isBodyPalace: false, isOriginalPalace: false, heavenlyStem: '辛', earthlyBranch: '巳', majorStars: [{ name: '天机', type: 'major', scope: 'origin', brightness: '平' }], minorStars: [], adjectiveStars: [ { name: '天喜', type: 'flower', scope: 'origin' }, { name: '天空', type: 'adjective', scope: 'origin' }, { name: '孤辰', type: 'adjective', scope: 'origin' }, ], changsheng12: '病', boshi12: '小耗', jiangqian12: '劫煞', suiqian12: '晦气', stage: { range: [14, 23], heavenlyStem: '辛' }, ages: [6, 18, 30, 42, 54, 66, 78], }, { name: '命宫', isBodyPalace: false, isOriginalPalace: false, heavenlyStem: '壬', earthlyBranch: '午', majorStars: [{ name: '紫微', type: 'major', scope: 'origin', brightness: '庙' }], minorStars: [{ name: '文曲', type: 'soft', scope: 'origin', brightness: '陷' }], adjectiveStars: [ { name: '年解', type: 'helper', scope: 'origin' }, { name: '凤阁', type: 'adjective', scope: 'origin' }, { name: '天福', type: 'adjective', scope: 'origin' }, { name: '截路', type: 'adjective', scope: 'origin' }, { name: '蜚廉', type: 'adjective', scope: 'origin' }, ], changsheng12: '衰', boshi12: '青龙', jiangqian12: '灾煞', suiqian12: '丧门', stage: { range: [4, 13], heavenlyStem: '壬' }, ages: [5, 17, 29, 41, 53, 65, 77], }, { name: '父母', isBodyPalace: false, isOriginalPalace: false, heavenlyStem: '癸', earthlyBranch: '未', majorStars: [], minorStars: [ { name: '天钺', type: 'soft', scope: 'origin', brightness: '' }, { name: '陀罗', type: 'tough', scope: 'origin', brightness: '庙' }, ], adjectiveStars: [ { name: '天姚', type: 'flower', scope: 'origin' }, { name: '空亡', type: 'adjective', scope: 'origin' }, ], changsheng12: '帝旺', boshi12: '力士', jiangqian12: '天煞', suiqian12: '贯索', stage: { range: [114, 123], heavenlyStem: '癸' }, ages: [4, 16, 28, 40, 52, 64, 76], }, { name: '福德', isBodyPalace: false, isOriginalPalace: false, heavenlyStem: '甲', earthlyBranch: '申', majorStars: [ { name: '破军', type: 'major', scope: 'origin', brightness: '得' }, { name: '禄存', type: 'lucun', scope: 'origin', brightness: '' }, ], minorStars: [{ name: '文昌', type: 'soft', scope: 'origin', brightness: '得' }], adjectiveStars: [ { name: '龙池', type: 'adjective', scope: 'origin' }, { name: '台辅', type: 'adjective', scope: 'origin' }, { name: '旬空', type: 'adjective', scope: 'origin' }, ], changsheng12: '临官', boshi12: '博士', jiangqian12: '指背', suiqian12: '官符', stage: { range: [104, 113], heavenlyStem: '甲' }, ages: [3, 15, 27, 39, 51, 63, 75], }, { name: '田宅', isBodyPalace: false, isOriginalPalace: false, heavenlyStem: '乙', earthlyBranch: '酉', majorStars: [], minorStars: [ { name: '地空', type: 'tough', scope: 'origin', brightness: '' }, { name: '擎羊', type: 'tough', scope: 'origin', brightness: '陷' }, ], adjectiveStars: [ { name: '咸池', type: 'flower', scope: 'origin' }, { name: '天贵', type: 'adjective', scope: 'origin' }, { name: '月德', type: 'adjective', scope: 'origin' }, ], changsheng12: '冠带', boshi12: '官府', jiangqian12: '咸池', suiqian12: '小耗', stage: { range: [94, 103], heavenlyStem: '乙' }, ages: [2, 14, 26, 38, 50, 62, 74], }, { name: '官禄', isBodyPalace: true, isOriginalPalace: false, heavenlyStem: '丙', earthlyBranch: '戌', majorStars: [ { name: '廉贞', type: 'major', scope: 'origin', brightness: '利' }, { name: '天府', type: 'major', scope: 'origin', brightness: '庙' }, ], minorStars: [{ name: '左辅', type: 'soft', scope: 'origin', brightness: '' }], adjectiveStars: [ { name: '天才', type: 'adjective', scope: 'origin' }, { name: '天虚', type: 'adjective', scope: 'origin' }, ], changsheng12: '沐浴', boshi12: '伏兵', jiangqian12: '月煞', suiqian12: '大耗', stage: { range: [84, 93], heavenlyStem: '丙' }, ages: [1, 13, 25, 37, 49, 61, 73], }, { name: '仆役', isBodyPalace: false, isOriginalPalace: false, heavenlyStem: '丁', earthlyBranch: '亥', majorStars: [{ name: '太阴', type: 'major', scope: 'origin', brightness: '庙' }], minorStars: [], adjectiveStars: [ { name: '红鸾', type: 'flower', scope: 'origin' }, { name: '恩光', type: 'adjective', scope: 'origin' }, { name: '天官', type: 'adjective', scope: 'origin' }, { name: '天月', type: 'adjective', scope: 'origin' }, { name: '天伤', type: 'adjective', scope: 'origin' }, ], changsheng12: '长生', boshi12: '大耗', jiangqian12: '亡神', suiqian12: '龙德', stage: { range: [74, 83], heavenlyStem: '丁' }, ages: [12, 24, 36, 48, 60, 72, 84], }, { name: '迁移', isBodyPalace: false, isOriginalPalace: false, heavenlyStem: '戊', earthlyBranch: '子', majorStars: [{ name: '贪狼', type: 'major', scope: 'origin', brightness: '旺' }], minorStars: [{ name: '铃星', type: 'tough', scope: 'origin', brightness: '陷' }], adjectiveStars: [{ name: ' 八座', type: 'adjective', scope: 'origin' }], changsheng12: '养', boshi12: '病符', jiangqian12: '将星', suiqian12: '白虎', stage: { range: [64, 73], heavenlyStem: '戊' }, ages: [11, 23, 35, 47, 59, 71, 83], }, { name: '疾厄', isBodyPalace: false, isOriginalPalace: false, heavenlyStem: '己', earthlyBranch: '丑', majorStars: [ { name: '天同', type: 'major', scope: 'origin', brightness: '不' }, { name: '巨门', type: 'major', scope: 'origin', brightness: '不' }, ], minorStars: [ { name: '天魁', type: 'soft', scope: 'origin', brightness: '' }, { name: '地劫', type: 'tough', scope: 'origin', brightness: '' }, ], adjectiveStars: [ { name: '天德', type: 'adjective', scope: 'origin' }, { name: '寡宿', type: 'adjective', scope: 'origin' }, { name: '破碎', type: 'adjective', scope: 'origin' }, { name: '天使', type: 'adjective', scope: 'origin' }, ], changsheng12: '胎', boshi12: '喜神', jiangqian12: '攀鞍', suiqian12: '天德', stage: { range: [54, 63], heavenlyStem: '己' }, ages: [10, 22, 34, 46, 58, 70, 82], }, ], }{ // 阳历日期 solarDate: '2000-8-16', // 农历日期 lunarDate: '二〇〇〇年七月十七', // 四柱 chineseDate: '庚辰 甲申 丙午 庚寅', // 时辰 time: '寅时', // 时辰对应的时间段 timeRange: '03:00~05:00', // 星座 sign: '狮子座', // 生肖 zodiac: '龙', // 命宫地支 earthlyBranchOfSoulPalace: '午', // 身宫地支 earthlyBranchOfBodyPalace: '戌', // 命主 soul: '破军', // 身主 body: '文昌', // 五行局 fiveElementsClass: '木三局', // 十二宫数据 palaces: [ { // 宫名 name: '财帛', // 是否身宫 isBodyPalace: false, // 是否来因宫 isOriginalPalace: false, // 宫位天干 heavenlyStem: '戊', // 宫位地支 earthlyBranch: '寅', // 主星(含天马禄存) majorStars: [ { name: '武曲', type: 'major', scope: 'origin', brightness: '得' }, { name: '天相', type: 'major', scope: 'origin', brightness: '庙' }, { name: '天马', type: 'tianma', scope: 'origin', brightness: '' }, ], // 辅星(含六吉六煞) minorStars: [], // 杂耀 adjectiveStars: [ { name: '月解', type: 'helper', scope: 'origin' }, { name: '三台', type: 'adjective', scope: 'origin' }, { name: '天寿', type: 'adjective', scope: 'origin' }, { name: '天巫', type: 'adjective', scope: 'origin' }, { name: '天厨', type: 'adjective', scope: 'origin' }, { name: '阴煞', type: 'adjective', scope: 'origin' }, { name: '天哭', type: 'adjective', scope: 'origin' }, ], // 长生12神 changsheng12: '绝', // 博士12神 boshi12: '蜚廉', // 流年将前12神 jiangqian12: '岁驿', // 流年岁前12神 suiqian12: '吊客', // 大限 stage: { range: [44, 53], heavenlyStem: '戊' }, // 小限 ages: [9, 21, 33, 45, 57, 69, 81], }, { name: '子女', isBodyPalace: false, isOriginalPalace: false, heavenlyStem: '己', earthlyBranch: '卯', majorStars: [ { name: '太阳', type: 'major', scope: 'origin', brightness: '庙' }, { name: '天梁', type: 'major', scope: 'origin', brightness: '庙' }, ], minorStars: [], adjectiveStars: [{ name: '天刑', type: 'adjective', scope: 'origin' }], changsheng12: '墓', boshi12: '奏书', jiangqian12: '息神', suiqian12: '病符', stage: { range: [34, 43], heavenlyStem: '己' }, ages: [8, 20, 32, 44, 56, 68, 80], }, { name: '夫妻', isBodyPalace: false, isOriginalPalace: true, heavenlyStem: '庚', earthlyBranch: '辰', majorStars: [{ name: '七杀', type: 'major', scope: 'origin', brightness: '庙' }], minorStars: [ { name: '右弼', type: 'soft', scope: 'origin', brightness: '' }, { name: '火星', type: 'tough', scope: 'origin', brightness: '陷' }, ], adjectiveStars: [ { name: '封诰', type: 'adjective', scope: 'origin' }, { name: '华盖', type: 'adjective', scope: 'origin' }, ], changsheng12: '死', boshi12: '将军', jiangqian12: '华盖', suiqian12: '岁建', stage: { range: [24, 33], heavenlyStem: '庚' }, ages: [7, 19, 31, 43, 55, 67, 79], }, { name: '兄弟', isBodyPalace: false, isOriginalPalace: false, heavenlyStem: '辛', earthlyBranch: '巳', majorStars: [{ name: '天机', type: 'major', scope: 'origin', brightness: '平' }], minorStars: [], adjectiveStars: [ { name: '天喜', type: 'flower', scope: 'origin' }, { name: '天空', type: 'adjective', scope: 'origin' }, { name: '孤辰', type: 'adjective', scope: 'origin' }, ], changsheng12: '病', boshi12: '小耗', jiangqian12: '劫煞', suiqian12: '晦气', stage: { range: [14, 23], heavenlyStem: '辛' }, ages: [6, 18, 30, 42, 54, 66, 78], }, { name: '命宫', isBodyPalace: false, isOriginalPalace: false, heavenlyStem: '壬', earthlyBranch: '午', majorStars: [{ name: '紫微', type: 'major', scope: 'origin', brightness: '庙' }], minorStars: [{ name: '文曲', type: 'soft', scope: 'origin', brightness: '陷' }], adjectiveStars: [ { name: '年解', type: 'helper', scope: 'origin' }, { name: '凤阁', type: 'adjective', scope: 'origin' }, { name: '天福', type: 'adjective', scope: 'origin' }, { name: '截路', type: 'adjective', scope: 'origin' }, { name: '蜚廉', type: 'adjective', scope: 'origin' }, ], changsheng12: '衰', boshi12: '青龙', jiangqian12: '灾煞', suiqian12: '丧门', stage: { range: [4, 13], heavenlyStem: '壬' }, ages: [5, 17, 29, 41, 53, 65, 77], }, { name: '父母', isBodyPalace: false, isOriginalPalace: false, heavenlyStem: '癸', earthlyBranch: '未', majorStars: [], minorStars: [ { name: '天钺', type: 'soft', scope: 'origin', brightness: '' }, { name: '陀罗', type: 'tough', scope: 'origin', brightness: '庙' }, ], adjectiveStars: [ { name: '天姚', type: 'flower', scope: 'origin' }, { name: '空亡', type: 'adjective', scope: 'origin' }, ], changsheng12: '帝旺', boshi12: '力士', jiangqian12: '天煞', suiqian12: '贯索', stage: { range: [114, 123], heavenlyStem: '癸' }, ages: [4, 16, 28, 40, 52, 64, 76], }, { name: '福德', isBodyPalace: false, isOriginalPalace: false, heavenlyStem: '甲', earthlyBranch: '申', majorStars: [ { name: '破军', type: 'major', scope: 'origin', brightness: '得' }, { name: '禄存', type: 'lucun', scope: 'origin', brightness: '' }, ], minorStars: [{ name: '文昌', type: 'soft', scope: 'origin', brightness: '得' }], adjectiveStars: [ { name: '龙池', type: 'adjective', scope: 'origin' }, { name: '台辅', type: 'adjective', scope: 'origin' }, { name: '旬空', type: 'adjective', scope: 'origin' }, ], changsheng12: '临官', boshi12: '博士', jiangqian12: '指背', suiqian12: '官符', stage: { range: [104, 113], heavenlyStem: '甲' }, ages: [3, 15, 27, 39, 51, 63, 75], }, { name: '田宅', isBodyPalace: false, isOriginalPalace: false, heavenlyStem: '乙', earthlyBranch: '酉', majorStars: [], minorStars: [ { name: '地空', type: 'tough', scope: 'origin', brightness: '' }, { name: '擎羊', type: 'tough', scope: 'origin', brightness: '陷' }, ], adjectiveStars: [ { name: '咸池', type: 'flower', scope: 'origin' }, { name: '天贵', type: 'adjective', scope: 'origin' }, { name: '月德', type: 'adjective', scope: 'origin' }, ], changsheng12: '冠带', boshi12: '官府', jiangqian12: '咸池', suiqian12: '小耗', stage: { range: [94, 103], heavenlyStem: '乙' }, ages: [2, 14, 26, 38, 50, 62, 74], }, { name: '官禄', isBodyPalace: true, isOriginalPalace: false, heavenlyStem: '丙', earthlyBranch: '戌', majorStars: [ { name: '廉贞', type: 'major', scope: 'origin', brightness: '利' }, { name: '天府', type: 'major', scope: 'origin', brightness: '庙' }, ], minorStars: [{ name: '左辅', type: 'soft', scope: 'origin', brightness: '' }], adjectiveStars: [ { name: '天才', type: 'adjective', scope: 'origin' }, { name: '天虚', type: 'adjective', scope: 'origin' }, ], changsheng12: '沐浴', boshi12: '伏兵', jiangqian12: '月煞', suiqian12: '大耗', stage: { range: [84, 93], heavenlyStem: '丙' }, ages: [1, 13, 25, 37, 49, 61, 73], }, { name: '仆役', isBodyPalace: false, isOriginalPalace: false, heavenlyStem: '丁', earthlyBranch: '亥', majorStars: [{ name: '太阴', type: 'major', scope: 'origin', brightness: '庙' }], minorStars: [], adjectiveStars: [ { name: '红鸾', type: 'flower', scope: 'origin' }, { name: '恩光', type: 'adjective', scope: 'origin' }, { name: '天官', type: 'adjective', scope: 'origin' }, { name: '天月', type: 'adjective', scope: 'origin' }, { name: '天伤', type: 'adjective', scope: 'origin' }, ], changsheng12: '长生', boshi12: '大耗', jiangqian12: '亡神', suiqian12: '龙德', stage: { range: [74, 83], heavenlyStem: '丁' }, ages: [12, 24, 36, 48, 60, 72, 84], }, { name: '迁移', isBodyPalace: false, isOriginalPalace: false, heavenlyStem: '戊', earthlyBranch: '子', majorStars: [{ name: '贪狼', type: 'major', scope: 'origin', brightness: '旺' }], minorStars: [{ name: '铃星', type: 'tough', scope: 'origin', brightness: '陷' }], adjectiveStars: [{ name: ' 八座', type: 'adjective', scope: 'origin' }], changsheng12: '养', boshi12: '病符', jiangqian12: '将星', suiqian12: '白虎', stage: { range: [64, 73], heavenlyStem: '戊' }, ages: [11, 23, 35, 47, 59, 71, 83], }, { name: '疾厄', isBodyPalace: false, isOriginalPalace: false, heavenlyStem: '己', earthlyBranch: '丑', majorStars: [ { name: '天同', type: 'major', scope: 'origin', brightness: '不' }, { name: '巨门', type: 'major', scope: 'origin', brightness: '不' }, ], minorStars: [ { name: '天魁', type: 'soft', scope: 'origin', brightness: '' }, { name: '地劫', type: 'tough', scope: 'origin', brightness: '' }, ], adjectiveStars: [ { name: '天德', type: 'adjective', scope: 'origin' }, { name: '寡宿', type: 'adjective', scope: 'origin' }, { name: '破碎', type: 'adjective', scope: 'origin' }, { name: '天使', type: 'adjective', scope: 'origin' }, ], changsheng12: '胎', boshi12: '喜神', jiangqian12: '攀鞍', suiqian12: '天德', stage: { range: [54, 63], heavenlyStem: '己' }, ages: [10, 22, 34, 46, 58, 70, 82], }, ], }
astrolabeByLunarDate
用途
通过农历日期获取星盘信息。我们强烈建议你优先使用
astrolabeBySolarDate方法,因为该方法也是将农历日期转化为阳历以后调用astrolabeBySolarDate获得结果的。定义
tsexport type astrolabeByLunarDate = ( lunarDateStr: string, timeIndex: number, gender: GenderName, isLeapMonth: boolean = false, fixLeap: boolean = true, language?: Language ) => FunctionalAstrolabe;export type astrolabeByLunarDate = ( lunarDateStr: string, timeIndex: number, gender: GenderName, isLeapMonth: boolean = false, fixLeap: boolean = true, language?: Language ) => FunctionalAstrolabe;参数
参数 类型 是否必填 默认值 说明 lunarDateStr stringtrue- 农历日期【YYYY-M-D】,例如 2000年七月十七则传入2000-7-17timeIndex numbertrue- 出生时辰序号【0~12】,对应从早子时(0)一直到晚子时(12)的序号 gender GenderNametrue- 性别【男/女】 isLeapMonth booleanfalsefalse是否闰月,当实际月份没有闰月时该参数不生效 fixLeap booleanfalsetrue是否调整闰月,为 true闰月的前半个月算上个月,后半个月算下个月language Languagefalsezh-CN返回数据将被国际化为指定语言。目前支持 zh-CN,zh-TW,en-US,ko-KR和ja-JP返回值
示例
tsimport { astro } from "iztro"; const astrolabe = astro.astrolabeBySolarDate("2000-8-16", 2, "女", false, true, "zh-CN");import { astro } from "iztro"; const astrolabe = astro.astrolabeBySolarDate("2000-8-16", 2, "女", false, true, "zh-CN");示例返回值
参考 astrolabeBySolarDate 的示例返回值
getMajorStarBySolarDate ^1.2.1
用途
通过阳历获取命宫主星
定义
tstype getMajorStarBySolarDate = ( solarDateStr: string, timeIndex: number, fixLeap: boolean = true, language?: Language, ) => string;type getMajorStarBySolarDate = ( solarDateStr: string, timeIndex: number, fixLeap: boolean = true, language?: Language, ) => string;参数
参数 类型 是否必填 默认值 说明 solarDateStr stringtrue- 阳历日期【YYYY-M-D】 timeIndex numbertrue- 出生时辰序号【0~12】,对应从早子时(0)一直到晚子时(12)的序号 fixLeap booleanfalsetrue是否调整闰月,为 true闰月的前半个月算上个月,后半个月算下个月language Languagefalsezh-CN返回数据将被国际化为指定语言。目前支持 zh-CN,zh-TW,en-US,ko-KR和ja-JP示例
tsimport { astro } from 'isztro'; const result = getMajorStarBySolarDate('2023-4-7', 0);import { astro } from 'isztro'; const result = getMajorStarBySolarDate('2023-4-7', 0);示例返回值
ts贪狼贪狼
getMajorStarByLunarDate ^1.2.1
用途
通过农历获取命宫主星
定义
tstype getMajorStarByLunarDate = ( lunarDateStr: string, timeIndex: number, isLeapMonth: boolean = false, fixLeap: boolean = true, language?: Language, ) =>type getMajorStarByLunarDate = ( lunarDateStr: string, timeIndex: number, isLeapMonth: boolean = false, fixLeap: boolean = true, language?: Language, ) =>参数
参数 类型 是否必填 默认值 说明 lunarDateStr stringtrue- 农历日期【YYYY-M-D】,例如 2000年七月十七则传入2000-7-17timeIndex numbertrue- 出生时辰序号【0~12】,对应从早子时(0)一直到晚子时(12)的序号 isLeapMonth booleanfalsefalse是否闰月,当实际月份没有闰月时该参数不生效 fixLeap booleanfalsetrue是否调整闰月,为 true闰月的前半个月算上个月,后半个月算下个月language Languagefalsezh-CN返回数据将被国际化为指定语言。目前支持 zh-CN,zh-TW,en-US,ko-KR和ja-JP示例
tsimport { astro } from 'isztro'; const result = getMajorStarByLunarDate('2023-2-17', 0, true, false);import { astro } from 'isztro'; const result = getMajorStarByLunarDate('2023-2-17', 0, true, false);示例返回值
ts紫微,贪狼紫微,贪狼
getSignBySolarDate ^1.2.1
用途
通过阳历获取星座
定义
tstype getSignBySolarDate = ( solarDateStr: string, language?: Language ) => string;type getSignBySolarDate = ( solarDateStr: string, language?: Language ) => string;参数
参数 类型 是否必填 默认值 说明 solarDateStr stringtrue- 阳历日期【YYYY-M-D】 language Languagefalsezh-CN返回数据将被国际化为指定语言。目前支持 zh-CN,zh-TW,en-US,ko-KR和ja-JP示例
tsimport { astro } from 'isztro'; const result = getSignBySolarDate('2023-9-5');import { astro } from 'isztro'; const result = getSignBySolarDate('2023-9-5');示例返回值
ts处女座处女座
getSignByLunarDate ^1.2.1
用途
通过农历获取星座
定义
tstype getSignByLunarDate = ( lunarDateStr: string, isLeapMonth?: boolean, language?: Language ) => string;type getSignByLunarDate = ( lunarDateStr: string, isLeapMonth?: boolean, language?: Language ) => string;参数
参数 类型 是否必填 默认值 说明 lunarDateStr stringtrue- 农历日期【YYYY-M-D】,例如 2000年七月十七则传入2000-7-17isLeapMonth booleanfalsefalse是否闰月,当实际月份没有闰月时该参数不生效 language Languagefalsezh-CN返回数据将被国际化为指定语言。目前支持 zh-CN,zh-TW,en-US,ko-KR和ja-JP示例
tsimport { astro } from 'isztro'; const result = getSignByLunarDate('2023-7-21');import { astro } from 'isztro'; const result = getSignByLunarDate('2023-7-21');示例返回值
ts处女座处女座
getZodiacBySolarDate ^1.2.1
用途
通过公历获取十二生肖
定义
tstype getZodiacBySolarDate = (solarDateStr: string, language?: Language) => string;type getZodiacBySolarDate = (solarDateStr: string, language?: Language) => string;参数
参数 类型 是否必填 默认值 说明 solarDateStr stringtrue- 阳历日期【YYYY-M-D】 language Languagefalsezh-CN返回数据将被国际化为指定语言。目前支持 zh-CN,zh-TW,en-US,ko-KR和ja-JP示例
tsimport { astro } from 'isztro'; const result = getZodiacBySolarDate('2023-2-20');import { astro } from 'isztro'; const result = getZodiacBySolarDate('2023-2-20');示例返回值
ts兔兔
getZodiacByLunarYear ^1.2.1
用途
通过农历年份获取十二生肖
定义
tstype getZodiacByLunarYear = (year: number, language?: Language) => string;type getZodiacByLunarYear = (year: number, language?: Language) => string;参数
参数 类型 是否必填 默认值 说明 year numbertrue- 农历年份 language Languagefalsezh-CN返回数据将被国际化为指定语言。目前支持 zh-CN,zh-TW,en-US,ko-KR和ja-JP示例
tsimport { astro } from 'isztro'; const result = getZodiacByLunarYear(2023);import { astro } from 'isztro'; const result = getZodiacByLunarYear(2023);示例返回值
ts兔兔
功能类定义
开发建议
我们推荐你直接调用 astro 的静态方法 来获取数据,而不是手动去创建一个 FunctionalAstrolabe 类的实例。
FunctionalAstrolabe
implements
IFunctionalAstrolabe extends Astrolabe该类所有属性都是继承自 Astrolabe,然后在接口内定义了一些方法用于对星盘的分析。astrolabeBySolarDate() 和 astrolabeByLunarDate() 方法会返回一个该类的实例。
接口定义
tsinterface IFunctionalAstrolabe extends Astrolabe { horoscope: (date?: string | Date, timeIndex?: number) => Horoscope; palace: (indexOrName: number | PalaceName) => IFunctionalPalace | undefined; surroundedPalaces: (indexOrName: number | PalaceName) => SurroundedPalaces; isSurrounded: ( indexOrName: number | PalaceName, stars: StarName[] ) => boolean; isSurroundedOneOf: ( indexOrName: number | PalaceName, stars: StarName[] ) => boolean; notSurrounded: ( indexOrName: number | PalaceName, stars: StarName[] ) => boolean; hasMutagenInSurroundedPalace: ( indexOrName: number | PalaceName, mutagen: Mutagen ) => boolean; hasMutagenInOppositePalace: ( indexOrName: number | PalaceName, mutagen: Mutagen ) => boolean; }interface IFunctionalAstrolabe extends Astrolabe { horoscope: (date?: string | Date, timeIndex?: number) => Horoscope; palace: (indexOrName: number | PalaceName) => IFunctionalPalace | undefined; surroundedPalaces: (indexOrName: number | PalaceName) => SurroundedPalaces; isSurrounded: ( indexOrName: number | PalaceName, stars: StarName[] ) => boolean; isSurroundedOneOf: ( indexOrName: number | PalaceName, stars: StarName[] ) => boolean; notSurrounded: ( indexOrName: number | PalaceName, stars: StarName[] ) => boolean; hasMutagenInSurroundedPalace: ( indexOrName: number | PalaceName, mutagen: Mutagen ) => boolean; hasMutagenInOppositePalace: ( indexOrName: number | PalaceName, mutagen: Mutagen ) => boolean; }属性
参考 Astrolabe
方法
horoscope() ^0.2.0
用途
获取运限数据。如果只是想获取调用时的运限数据,可以不传任何参数,该方法会获取系统当前时间进行计算。
注意
- 当
date为YYYY-M-D格式的字符串而没有传timeIndex参数时,会取date当日早子时的时间点作为流时的时间 - 当
date为YYYY-M-D HH格式时间或是一个Date实例而没有传timeIndex参数时,会将date里的小时转化为时辰作为流时的时间 - 当传入
timeIndex参数时,会优先使用该参数
- 当
定义
tstype horoscope = (date?: string | Date, timeIndex?: number) => Horoscope;type horoscope = (date?: string | Date, timeIndex?: number) => Horoscope;参数
参数 类型 是否必填 默认值 说明 date string|Datefalsenew Date()阳历日期【YYYY-M-D】 timeIndex numberfalse0时辰索引【0~12】 返回值
示例
tsimport { astro } from "iztro"; const astrolabe = astro.astrolabeBySolarDate("2000-8-16", 2, "女", true, "zh-CN"); const horoscope = astrolabe.horoscope();import { astro } from "iztro"; const astrolabe = astro.astrolabeBySolarDate("2000-8-16", 2, "女", true, "zh-CN"); const horoscope = astrolabe.horoscope();
star() ^1.2.0
用途
通过星耀名称获取到当前星耀的对象实例
定义
tstype star = (starName: StarName) => IFunctionalStar;type star = (starName: StarName) => IFunctionalStar;参数
参数 类型 是否必填 默认值 说明 starName StarNametrue- 星耀名称 返回值
示例
tsimport { astro } from "iztro"; const astrolabe = astro.astrolabeBySolarDate("2000-8-16", 2, "女", true, "zh-CN"); // 获取 `紫微星` 所在宫位 const star = astrolabe.star("紫微");import { astro } from "iztro"; const astrolabe = astro.astrolabeBySolarDate("2000-8-16", 2, "女", true, "zh-CN"); // 获取 `紫微星` 所在宫位 const star = astrolabe.star("紫微");
palace() ^1.0.0
用途
获取星盘的指定
宫位定义
tstype palace = ( indexOrName: number | PalaceName ) => IFunctionalPalace | undefined;type palace = ( indexOrName: number | PalaceName ) => IFunctionalPalace | undefined;参数
参数 类型 是否必填 默认值 说明 indexOrName number|PalaceNametrue- 宫位索引或者宫位名称 返回值
示例
tsimport { astro } from "iztro"; const astrolabe = astro.astrolabeBySolarDate("2000-8-16", 2, "女", true, "zh-CN"); // 获取 `寅宫` const palace = astrolabe.palace(0); // 获取 `命宫` const soulPalace = astrolabe.palace("命宫");import { astro } from "iztro"; const astrolabe = astro.astrolabeBySolarDate("2000-8-16", 2, "女", true, "zh-CN"); // 获取 `寅宫` const palace = astrolabe.palace(0); // 获取 `命宫` const soulPalace = astrolabe.palace("命宫");
surroundedPalaces() ^1.1.0
用途
获取
三方四正宫位,所谓三方四正就是传入的目标宫,以及其对宫,财帛位和官禄位,总共四个宫位。宫和位是两个概念,如果你对宫位和三方四正的概念不清楚,可以点击 宫位 查看详细信息。定义
tstype surroundedPalaces = ( indexOrName: number | PalaceName ) => IFunctionalSurpalaces;type surroundedPalaces = ( indexOrName: number | PalaceName ) => IFunctionalSurpalaces;参数
参数 类型 是否必填 默认值 说明 indexOrName number|PalaceNametrue- 宫位索引或者宫位名称 返回值
示例
tsimport { astro } from "iztro"; const astrolabe = astro.astrolabeBySolarDate("2000-8-16", 2, "女", true, "zh-CN"); // 获取 `寅宫` 三方四正 const surroundedPalaces = astrolabe.surroundedPalaces(0); // 获取 `命宫` 三方四正 const surroundedPalacesOfSoul = astrolabe.surroundedPalaces("命宫");import { astro } from "iztro"; const astrolabe = astro.astrolabeBySolarDate("2000-8-16", 2, "女", true, "zh-CN"); // 获取 `寅宫` 三方四正 const surroundedPalaces = astrolabe.surroundedPalaces(0); // 获取 `命宫` 三方四正 const surroundedPalacesOfSoul = astrolabe.surroundedPalaces("命宫");
isSurrounded() ^1.0.0 deprecated
注意
该方法已经在
v1.2.0废弃,请使用 FunctionalSurpalaces 的 have() 方法代替用途
判断某一个宫位
三方四正是否包含目标星耀,必须要全部包含才会返回true定义
tstype isSurrounded = ( indexOrName: number | PalaceName, stars: StarName[] ) => boolean;type isSurrounded = ( indexOrName: number | PalaceName, stars: StarName[] ) => boolean;参数
参数 类型 是否必填 默认值 说明 indexOrName number|PalaceNametrue- 宫位索引或者宫位名称 stars StarName[]true- 星耀名称数组 返回值
boolean示例
tsimport { astro } from "iztro"; const astrolabe = astro.astrolabeBySolarDate("2000-8-16", 2, "女", true, "zh-CN"); // 判断 `寅宫` 三方四正是否含有 `天府` 星、`红鸾` 星和 `禄存` 星 const palace = astrolabe.isSurrounded(0, ["天府", "红鸾", "禄存"]); // 判断 `命宫` 三方四正是否含有 `天府` 星、`红鸾` 星和 `禄存` 星 const soulPalace = astrolabe.isSurrounded("命宫", ["天府", "红鸾", "禄存"]);import { astro } from "iztro"; const astrolabe = astro.astrolabeBySolarDate("2000-8-16", 2, "女", true, "zh-CN"); // 判断 `寅宫` 三方四正是否含有 `天府` 星、`红鸾` 星和 `禄存` 星 const palace = astrolabe.isSurrounded(0, ["天府", "红鸾", "禄存"]); // 判断 `命宫` 三方四正是否含有 `天府` 星、`红鸾` 星和 `禄存` 星 const soulPalace = astrolabe.isSurrounded("命宫", ["天府", "红鸾", "禄存"]);
isSurroundedOneOf() ^1.1.0 deprecated
注意
该方法已经在
v1.2.0废弃,请使用 FunctionalSurpalaces 的 haveOneOf() 方法代替用途
判断指定宫位
三方四正内是否有传入星耀的其中一个,只要命中一个就会返回true定义
tstype isSurroundedOneOf = ( indexOrName: number | PalaceName, stars: StarName[] ) => boolean;type isSurroundedOneOf = ( indexOrName: number | PalaceName, stars: StarName[] ) => boolean;参数
参数 类型 是否必填 默认值 说明 indexOrName number|PalaceNametrue- 宫位索引或者宫位名称 stars StarName[]true- 星耀名称数组 返回值
boolean示例
tsimport { astro } from "iztro"; const astrolabe = astro.astrolabeBySolarDate("2000-8-16", 2, "女", true, "zh-CN"); // 判断 `寅宫` 三方四正是否含有 `天府` 星、`红鸾` 星和 `禄存` 星中的一颗 const palace = astrolabe.isSurroundedOneOf(0, ["天府", "红鸾", "禄存"]); // 判断 `命宫` 三方四正是否含有 `天府` 星、`红鸾` 星和 `禄存` 星中的一颗 const soulPalace = astrolabe.isSurroundedOneOf("命宫", ["天府", "红鸾", "禄存"]);import { astro } from "iztro"; const astrolabe = astro.astrolabeBySolarDate("2000-8-16", 2, "女", true, "zh-CN"); // 判断 `寅宫` 三方四正是否含有 `天府` 星、`红鸾` 星和 `禄存` 星中的一颗 const palace = astrolabe.isSurroundedOneOf(0, ["天府", "红鸾", "禄存"]); // 判断 `命宫` 三方四正是否含有 `天府` 星、`红鸾` 星和 `禄存` 星中的一颗 const soulPalace = astrolabe.isSurroundedOneOf("命宫", ["天府", "红鸾", "禄存"]);
notSurrounded() ^1.1.0 deprecated
注意
该方法已经在
v1.2.0废弃,请使用 FunctionalSurpalaces 的 notHave() 方法代替用途
判断指定宫位
三方四正是否不含目标星耀,必须要全部都不在三方四正内含才会返回true定义
tstype notSurrounded = ( indexOrName: number | PalaceName, stars: StarName[] ) => boolean;type notSurrounded = ( indexOrName: number | PalaceName, stars: StarName[] ) => boolean;参数
参数 类型 是否必填 默认值 说明 indexOrName number|PalaceNametrue- 宫位索引或者宫位名称 stars StarName[]true- 星耀名称数组 返回值
boolean示例
tsimport { astro } from "iztro"; const astrolabe = astro.astrolabeBySolarDate("2000-8-16", 2, "女", true, "zh-CN"); // 判断 `寅宫` 三方四正是否不含有 `天府` 星、`红鸾` 星和 `禄存` 星 const palace = astrolabe.notSurrounded(0, ["天府", "红鸾", "禄存"]); // 判断 `命宫` 三方四正是否不含有 `天府` 星、`红鸾` 星和 `禄存` 星 const soulPalace = astrolabe.notSurrounded("命宫", ["天府", "红鸾", "禄存"]);import { astro } from "iztro"; const astrolabe = astro.astrolabeBySolarDate("2000-8-16", 2, "女", true, "zh-CN"); // 判断 `寅宫` 三方四正是否不含有 `天府` 星、`红鸾` 星和 `禄存` 星 const palace = astrolabe.notSurrounded(0, ["天府", "红鸾", "禄存"]); // 判断 `命宫` 三方四正是否不含有 `天府` 星、`红鸾` 星和 `禄存` 星 const soulPalace = astrolabe.notSurrounded("命宫", ["天府", "红鸾", "禄存"]);