iOS 实现黄历算法三
上一章:iOS 实现黄历算法二
上章是写的宜忌
这章就把剩下的冲煞,五行,彭祖还有吉凶写了至于星宿暂时还没思路 对了还有节气这个就要看下了 剩下的还要一两章
那么继续上图:
数据源就有点长了,用文本吧!
//干支,纳音,岁数,男,女
-(NSArray*)numsix{
if(!_numsix){
_numsix = @[@[@"丙戌",@"屋上土",@"厨灶栖外西北",@"冲龙(庚辰)煞北",@"西南|正东|西南",@"凶|凶|吉|凶|吉|吉|凶|凶|吉|吉|凶|吉",@"1",@"3",@"3"],
@[@"乙酉",@"泉中水",@"碓磨门外西北",@"冲兔(己卯)煞东",@"西北|东南|东北",@"吉|凶|吉|吉|凶|凶|吉|吉|凶|吉|凶|凶",@"2",@"4",@"2"],
@[@"甲申",@"泉中水",@"占门炉外西北",@"冲虎(戊寅)煞南",@"东北|东南|东北",@"吉|吉|凶|凶|吉|吉|凶|吉|凶|凶|吉|凶",@"3",@"5",@"1"],
@[@"癸未",@"杨柳木",@"房床厕外西北",@"冲牛(丁丑)煞西",@"东南|正西|正南",@"凶|凶|吉|吉|凶|吉|凶|凶|吉|凶|吉|吉",@"4",@"6",@"9"],
@[@"壬午",@"杨柳木",@"仓库碓外西北",@"冲鼠(丙子)煞北",@"正南|西北|正南",@"吉|吉|凶|吉|凶|凶|吉|凶|吉|吉|凶|凶",@"5",@"7",@"8"],
@[@"辛巳",@"白蜡金",@"厨灶床外正西",@"冲猪(乙亥)煞东",@"西南|西南|正东",@"凶|吉|凶|凶|吉|凶|吉|吉|凶|凶|吉|凶",@"6",@"8",@"7"],
@[@"庚辰",@"白蜡金",@"碓磨栖外正西",@"冲狗(甲戌)煞南",@"西北|西南|正东",@"凶|凶|吉|凶|吉|吉|凶|凶|凶|吉|凶|吉",@"7",@"9",@"6"],
@[@"己卯",@"城墙土",@"占门厕外正南",@"冲鸡(癸酉)煞西",@"东北|正南|正北",@"吉|凶|吉|吉|凶|凶|吉|吉|凶|吉|凶|凶",@"8",@"1",@"5"],
@[@"戊寅",@"城墙土",@"房床厕外正南",@"冲猴(壬申)煞北",@"东南|正北|正北",@"吉|吉|凶|凶|吉|吉|凶|吉|凶|凶|吉|凶",@"9",@"2",@"4"],
@[@"丁丑",@"涧下水",@"仓库厕外西南",@"冲羊(辛未)煞东",@"正南|正东|西南",@"凶|凶|吉|吉|凶|吉|凶|凶|吉|凶|吉|吉",@"10",@"3",@"3"],
@[@"丙子",@"涧下水",@"厨灶碓外西南",@"冲马(庚午)煞南",@"西南|正东|西南",@"吉|吉|凶|吉|凶|凶|吉|凶|吉|吉|凶|凶",@"11",@"4",@"2"],
@[@"乙亥",@"山头火",@"碓磨床外西南",@"冲蛇(己已)煞西",@"西北|东南|东北",@"凶|吉|凶|凶|吉|凶|吉|凶|凶|凶|吉|吉",@"12",@"5",@"1"],
@[@"甲戌",@"山头火",@"门鸡栖外西南",@"冲龙(戊辰)煞北",@"东北|东南|东北",@"凶|凶|吉|凶|吉|吉|凶|吉|吉|吉|凶|吉",@"13",@"6",@"9"],
@[@"癸酉",@"剑锋金",@"房床门外西南",@"冲兔(丁卯)煞东",@"东南|正西|正南",@"吉|凶|吉|吉|凶|凶|吉|吉|凶|吉|凶|凶",@"14",@"7",@"8"],
@[@"壬申",@"剑锋金",@"仓库炉外西南",@"冲虎(丙寅)煞南",@"正南|西北|正南",@"吉|吉|凶|凶|吉|吉|凶|吉|凶|凶|吉|凶",@"15",@"8",@"7"],
@[@"辛未",@"路旁土",@"厨灶厕外西南",@"冲牛(乙丑)煞西",@"西南|西南|正东",@"凶|凶|吉|吉|凶|吉|凶|凶|吉|凶|吉|吉",@"16",@"9",@"6"],
@[@"庚午",@"路旁土",@"占碓磨外正南",@"冲鼠(甲子)煞北",@"西北|西南|正东",@"吉|吉|凶|吉|凶|凶|吉|凶|吉|吉|凶|凶",@"17",@"1",@"5"],
@[@"己巳",@"大林木",@"占门床外正南",@"冲猪(癸亥)煞东",@"东北|正南|正北",@"凶|吉|凶|凶|吉|凶|吉|吉|凶|凶|吉|吉",@"18",@"2",@"4"],
@[@"戊辰",@"大林木",@"房床栖外正南",@"冲狗(壬戌)煞南",@"东南|正北|正北",@"凶|凶|吉|凶|吉|吉|凶|凶|吉|吉|凶|吉",@"19",@"3",@"3"],
@[@"丁卯",@"炉中火",@"仓库门外正南",@"冲鸡(辛酉)煞西",@"正南|正东|西南",@"吉|凶|吉|吉|凶|凶|吉|吉|凶|吉|凶|凶",@"20",@"4",@"2"],
@[@"丙寅",@"炉中火",@"厨灶炉外正南",@"冲猴(庚申)煞北",@"西南|正东|西南",@"吉|吉|凶|凶|吉|吉|凶|吉|凶|凶|吉|凶",@"21",@"5",@"1"],
@[@"乙丑",@"海中金",@"碓磨厕外东南",@"冲羊(己未)煞东",@"西北|东南|东北",@"凶|凶|吉|吉|凶|吉|凶|凶|吉|凶|吉|吉",@"22",@"6",@"9"],
@[@"甲子",@"海中金",@"占门碓外东南",@"冲马(戊午)煞南",@"东北|东南|东北",@"吉|吉|凶|吉|凶|凶|吉|凶|吉|吉|凶|凶",@"23",@"7",@"8"],
@[@"癸亥",@"大海水",@"占房床外东南",@"冲蛇(丁已)煞西",@"东南|正西|正南",@"凶|吉|凶|凶|吉|凶|吉|吉|凶|凶|吉|吉",@"24",@"8",@"7"],
@[@"壬戌",@"大海水",@"仓库栖外东南",@"冲龙(丙辰)煞北",@"正南|西北|正南",@"凶|凶|吉|凶|吉|吉|凶|凶|吉|吉|凶|吉",@"25",@"9",@"6"],
@[@"辛酉",@"石榴木",@"厨灶门外东南",@"冲兔(乙卯)煞东",@"西南|西南|正东",@"吉|凶|吉|吉|凶|凶|吉|吉|凶|吉|凶|凶",@"26",@"1",@"5"],
@[@"庚申",@"石榴木",@"碓磨炉外东南",@"冲虎(甲寅)煞南",@"西北|西南|正东",@"吉|吉|凶|凶|吉|吉|吉|吉|凶|凶|吉|凶",@"27",@"2",@"4"],
@[@"己未",@"天上火",@"占门厕外正东",@"冲牛(癸丑)煞西",@"东北|正南|正北",@"凶|凶|吉|吉|凶|吉|凶|凶|吉|凶|吉|吉",@"28",@"3",@"3"],
@[@"戊午",@"天上火",@"房床碓外正东",@"冲鼠(壬子)煞北",@"东南|正北|正北",@"吉|吉|凶|吉|凶|凶|吉|凶|吉|吉|凶|凶",@"29",@"4",@"2"],
@[@"丁巳",@"沙中土",@"仓库床外正东",@"冲猪(辛亥)煞东",@"正南|正东|西南",@"凶|吉|凶|凶|吉|凶|吉|吉|凶|凶|吉|吉",@"30",@"5",@"1"],
@[@"丙辰",@"沙中土",@"厨灶栖外正东",@"冲狗(庚戌)煞南",@"西南|正东|西南",@"凶|凶|吉|凶|吉|吉|凶|凶|吉|吉|凶|吉",@"31",@"6",@"9"],
@[@"乙卯",@"大溪水",@"碓磨门外正东",@"冲鸡(己酉)煞西",@"西北|东南|东北",@"吉|凶|吉|吉|凶|凶|吉|吉|凶|吉|凶|凶",@"32",@"7",@"8"],
@[@"甲寅",@"大溪水",@"占门炉外东北",@"冲猴(戊申)煞北",@"东北|东南|东北",@"吉|吉|凶|凶|吉|吉|凶|吉|凶|凶|吉|凶",@"33",@"8",@"7"],
@[@"癸丑",@"桑松木",@"房床厕外东北",@"冲羊(丁未)煞东",@"东南|正西|正南",@"凶|凶|吉|吉|凶|吉|凶|凶|吉|凶|吉|吉",@"34",@"9",@"6"],
@[@"壬子",@"桑松木",@"仓库碓外东北",@"冲马(丙午)煞南",@"正南|西北|正南",@"吉|吉|凶|吉|凶|凶|吉|凶|吉|吉|凶|凶",@"35",@"1",@"5"],
@[@"辛亥",@"钗钏金",@"厨灶床外东北",@"冲蛇(乙已)煞西",@"西南|西南|正东",@"凶|吉|凶|凶|吉|凶|吉|凶|凶|凶|吉|吉",@"36",@"2",@"4"],
@[@"庚戌",@"钗钏金",@"碓磨栖外东北",@"冲龙(甲辰)煞北",@"西北|西南|正东",@"凶|凶|吉|凶|吉|吉|凶|凶|吉|吉|凶|吉",@"37",@"3",@"3"],
@[@"己酉",@"大驿土",@"占大门外东北",@"冲兔(癸卯)煞东",@"东北|正南|正北",@"吉|凶|吉|吉|凶|凶|吉|吉|凶|吉|凶|凶",@"38",@"4",@"2"],
@[@"戊申",@"大驿土",@"房床炉房内东",@"冲虎(壬寅)煞南",@"东南|正北|正北",@"吉|吉|凶|凶|吉|吉|凶|吉|凶|凶|吉|凶",@"39",@"5",@"1"],
@[@"丁未",@"天河水",@"仓库厕房内东",@"冲牛(辛丑)煞西",@"正南|正东|西南",@"凶|凶|吉|吉|凶|吉|凶|凶|吉|凶|吉|吉",@"40",@"6",@"9"],
@[@"丙午",@"天河水",@"厨灶碓房内东",@"冲鼠(庚子)煞北",@"西南|正东|西南",@"吉|吉|凶|吉|凶|凶|吉|凶|吉|凶|凶|凶",@"41",@"7",@"8"],
@[@"乙巳",@"佛灯火",@"碓磨床房内东",@"冲猪(己亥)煞东",@"西北|东南|东北",@"凶|吉|凶|凶|吉|凶|吉|凶|凶|凶|吉|吉",@"42",@"8",@"7"],
@[@"甲辰",@"佛灯火",@"门鸡栖房内东",@"冲狗(戊戌)煞南",@"东北|东南|东北",@"凶|凶|吉|凶|吉|吉|凶|凶|吉|吉|凶|吉",@"43",@"9",@"6"],
@[@"癸卯",@"金箔金",@"房床门房内南",@"冲鸡(丁酉)煞西",@"东南|正西|正南",@"吉|凶|吉|吉|凶|凶|吉|凶|凶|吉|凶|凶",@"44",@"1",@"5"],
@[@"壬寅",@"金箔金",@"仓库炉房内南",@"冲猴(丙申)煞北",@"正南|西北|正南",@"吉|吉|凶|凶|吉|吉|凶|吉|凶|凶|吉|凶",@"45",@"2",@"4"],
@[@"辛丑",@"壁上土",@"厨灶厕房内南",@"冲羊(乙未)煞东",@"西南|西南|正东",@"凶|凶|吉|吉|凶|吉|凶|凶|吉|凶|吉|吉",@"46",@"3",@"3"],
@[@"庚子",@"壁上土",@"占碓磨房内南",@"冲马(甲午)煞南",@"西北|西南|正东",@"吉|吉|凶|吉|凶|凶|吉|凶|吉|吉|凶|凶",@"47",@"4",@"2"],
@[@"己亥",@"平地木",@"占门床房内南",@"冲蛇(癸已)煞西",@"东北|正南|正北",@"凶|吉|凶|凶|吉|凶|吉|吉|凶|凶|吉|吉",@"48",@"5",@"1"],
@[@"戊戌",@"平地木",@"房床栖房内南",@"冲龙(壬辰)煞北",@"东南|正北|正北",@"凶|凶|吉|凶|吉|吉|凶|凶|吉|吉|凶|吉",@"49",@"6",@"9"],
@[@"丁酉",@"山下火",@"仓库门房内北",@"冲兔(辛卯)煞东",@"正南|正东|西南",@"吉|凶|吉|吉|凶|凶|吉|吉|凶|吉|凶|凶",@"50",@"7",@"8"],
@[@"丙申",@"山下火",@"厨灶炉房内北",@"冲虎(庚寅)煞南",@"西南|正东|西南",@"吉|吉|凶|凶|吉|吉|凶|吉|凶|凶|吉|凶",@"51",@"8",@"7"],
@[@"乙未",@"沙中金",@"碓磨厕房内北",@"冲牛(己丑)煞西",@"西北|东南|东北",@"凶|凶|吉|吉|凶|吉|凶|凶|吉|凶|吉|吉",@"52",@"9",@"6"],
@[@"甲午",@"沙中金",@"占门碓房内北",@"冲鼠(戊子)煞北",@"东北|东南|东北",@"吉|吉|凶|吉|凶|凶|吉|凶|吉|吉|凶|凶",@"53",@"1",@"5"],
@[@"癸巳",@"长流水",@"占房床房内北",@"冲猪(丁亥)煞东",@"东南|正西|正南",@"凶|吉|凶|凶|吉|凶|吉|吉|凶|凶|吉|吉",@"54",@"2",@"4"],
@[@"壬辰",@"长流水",@"仓库栖外正北",@"冲狗(丙戌)煞南",@"正南|西北|正南",@"凶|凶|吉|凶|吉|吉|凶|凶|吉|吉|凶|吉",@"55",@"3",@"3"],
@[@"辛卯",@"松柏木",@"厨灶门外正北",@"冲鸡(乙酉)煞西",@"西南|西南|正东",@"吉|凶|吉|吉|凶|凶|吉|吉|凶|吉|凶|凶",@"56",@"4",@"2"],
@[@"庚寅",@"松柏木",@"碓磨炉外正北",@"冲猴(甲申)煞北",@"西北|西南|正东",@"吉|吉|凶|凶|吉|吉|凶|吉|凶|凶|吉|凶",@"57",@"5",@"1"],
@[@"己丑",@"霹雳火",@"占门厕外正北",@"冲羊(癸未)煞东",@"东北|正南|正北",@"凶|凶|吉|吉|凶|吉|凶|凶|吉|凶|吉|凶",@"58",@"6",@"9"],
@[@"戊子",@"霹雳火",@"房床碓外正北",@"冲马(壬午)煞南",@"东南|正北|正北",@"吉|吉|凶|吉|凶|凶|吉|凶|吉|吉|凶|凶",@"59",@"7",@"8"],
@[@"丁亥",@"屋上土",@"仓库床外西北",@"冲蛇(辛已)煞西",@"正南|正东|西南",@"凶|吉|凶|凶|吉|凶|吉|吉|凶|凶|吉|吉",@"60",@"8",@"7"],];
}
return _numsix;
}
-(NSArray*)shensha1{
if(!_shensha1) {
_shensha1=@[
@[@"碎",@"狼籍",@"飞天",@"八败",@"大狼籍",@"大败",@"相冲",@"劫煞",@"咸池",@"头蒂",@"在嫁",@"女扫男家",@"男扫女家",@"女破男家",@"男破女家",@"生年"],
@[@"四",@"三",@"二",@"六",@"五",@"四",@"八",@"四",@"八",@"五",@"五",@"十二",@"正",@"六",@"二",@"子"],
@[@"十二",@"七",@"正",@"九",@"八",@"七",@"九",@"正",@"五",@"六",@"六",@"九",@"六",@"四",@"三",@"丑"],
@[@"八",@"六",@"五",@"十二",@"十一",@"十",@"十",@"十",@"二",@"七",@"七",@"七",@"四",@"三",@"十",@"寅"],
@[@"四",@"六",@"五",@"十二",@"十二",@"十",@"十一",@"七",@"十一",@"八",@"八",@"八",@"二",@"正",@"五",@"卯"],
@[@"十二",@"二",@"三",@"六",@"五",@"四",@"十二",@"四",@"八",@"九",@"九",@"十二",@"正",@"六",@"十二",@"辰"],
@[@"八",@"二",@"三",@"六",@"五",@"四",@"正",@"正",@"五",@"十",@"十",@"九",@"六",@"四",@"正",@"巳"],
@[@"四",@"六",@"五",@"十二",@"十一",@"十",@"八",@"十",@"二",@"十一",@"十一",@"七",@"四",@"三",@"八",@"午"],
@[@"十二",@"十一",@"十",@"三",@"二",@"正",@"九",@"七",@"十一",@"十二",@"十二",@"八",@"二",@"正",@"九",@"未"],
@[@"八",@"七",@"正",@"三",@"八",@"七",@"十",@"四",@"八",@"正",@"正",@"十二",@"正",@"六",@"四",@"申"],
@[@"四",@"七",@"正",@"三",@"八",@"七",@"十一",@"正",@"五",@"六",@"六",@"九",@"六",@"四",@"十一",@"酉"],
@[@"十二",@"十一",@"十",@"九",@"二",@"正",@"十二",@"十",@"二",@"四",@"四",@"七",@"四",@"三",@"六",@"戌"],
@[@"八",@"十一",@"十",@"九",@"二",@"正",@"正",@"七",@"十一",@"二",@"二",@"八",@"二",@"正",@"七",@"亥"],
];
}
return _shensha1;
}
-(NSArray*)shensha2{
if(!_shensha2) {
_shensha2=@[
@[@"旺门寡",@"多厄",@"女妨夫",@"望门",@"多厄",@"男妨妻",@"胞胎",@"亡 神",@"脚 踏",@"绝房",@"重婚",@"寡宿",@"孤辰",@"小狼籍",@"小狼籍",@"生年"],
@[@"十",@"八九",@"金",@"七",@"五六",@"金",@"二",@"十",@"四",@"十一",@"四",@"九",@"正",@"九",@"四",@"子"],
@[@"正",@"十一十二",@"无",@"正",@"二三",@"木",@"三",@"七",@"五",@"二",@"五",@"九",@"正",@"十",@"八",@"丑"],
@[@"四",@"二三",@"无",@"十",@"八九",@"水",@"四",@"四",@"六",@"七",@"六",@"十二",@"四",@"十二",@"十",@"寅"],
@[@"四",@"五六",@"无",@"正",@"十一十二",@"火",@"五",@"正",@"七",@"十一",@"七",@"十二",@"四",@"九",@"四",@"卯"],
@[@"七",@"无",@"土命",@"四",@"二三",@"土",@"六",@"十",@"八",@"二",@"八",@"十二",@"四",@"九",@"四",@"辰"],
@[@"无",@"无",@"无",@"无",@"无",@"无",@"七",@"七",@"九",@"七",@"九",@"三",@"七",@"十二",@"十",@"巳"],
@[@"无",@"无",@"无",@"无",@"无",@"无",@"二",@"四",@"十",@"十一",@"十",@"三",@"七",@"六",@"二",@"午"],
@[@"无",@"无",@"无",@"无",@"无",@"无",@"三",@"正",@"十一",@"二",@"十一",@"三",@"七",@"十",@"八",@"未"],
@[@"无",@"无",@"无",@"无",@"无",@"无",@"四",@"十",@"十二",@"七",@"十二",@"六",@"十",@"十",@"八",@"申"],
@[@"无",@"无",@"无",@"无",@"无",@"无",@"五",@"七",@"正",@"十一",@"正",@"六",@"十",@"六",@"二",@"酉"],
@[@"无",@"无",@"无",@"无",@"无",@"无",@"六",@"四",@"二",@"二",@"二",@"六",@"十",@"六",@"二",@"戌"],
@[@"无",@"无",@"无",@"无",@"无",@"无",@"七",@"七",@"三",@"七",@"三",@"九",@"正",@"二",@"十",@"亥"],];
}
return _shensha2;
}
-(NSArray*)zhi{
if(!_zhi) {
_zhi = @[@"子",@"丑",@"寅",@"卯",@"辰",@"巳",@"午",@"未",@"申",@"酉",@"戌",@"亥"];
}
return _zhi;
}
/**
*
*@paramyear 年份
*@return返回纳音
*/
-(NSString*)getnumsix:(NSString*)year{
for(inti =0; i <60; i++) {
if([yearisEqualToString:self.numsix[i][0]]) {
returnself.numsix[i][1];
}
}
return nil;
}
/**
* 胎神
*@paramday 日柱
*@return..
*/
-(NSString*)getTai:(NSString*)day{
for(inti =0; i <60; i++) {
if([dayisEqualToString:self.numsix[i][0]]) {
returnself.numsix[i][2];
}
}
return nil;
}
/**
* 吉凶
*@paramday 日柱
*@return..
*/
-(NSString*)getJiXiong:(NSString*)day{
for(inti =0; i <60; i++) {
if([dayisEqualToString:self.numsix[i][0]]) {
returnself.numsix[i][5];
}
}
return nil;
}
/**
* 冲煞
*@paramday 日柱
*@return..
*/
-(NSString*)getChongSha:(NSString*)day{
for(inti =0; i <60; i++) {
if([dayisEqualToString:self.numsix[i][0]]) {
returnself.numsix[i][3];
}
}
return nil;
}
//获取五行日纳音
-(NSString*)wuxingRi:(NSString*)marr{
NSArray *array = [marrcomponentsSeparatedByString:@","];
NSString* ganziday = array[2];//日柱
returnganziday;
}
-(void)marriage:(NSString*)marr{
NSArray *array = [marrcomponentsSeparatedByString:@","];
NSString* ganziyear = array[0];//年柱
NSString* ganzimonth = array[1];//月柱
NSString* ganziday = array[2];//日柱
NSString* ganzitime = array[3];//时柱
//五行纳音
NSString* soundyear = [selfgetnumsix:ganziyear];
NSString* soundmonth = [selfgetnumsix:ganzimonth];
NSString* soundday = [selfgetnumsix:ganziday];
NSString* soundtime = [selfgetnumsix:ganzitime];
NSLog(@"年:%@。 月:%@ 日:……%@ 时:%@",soundyear,soundmonth,soundday,soundtime);
NSLog(@"五行:%@",soundyear);
NSString* tai = [selfgetTai:ganziday];
NSLog(@"胎神:%@",tai);
NSString* jx = [selfgetJiXiong:ganziday];
NSLog(@"吉凶:%@",jx);
NSString* cs = [selfgetChongSha:ganziday];
NSLog(@"冲煞:%@",cs);
}
以上基本上就是除了彭祖以外的了
彭祖就看下图吧:
数据源呢就是下面这张图 这是数据源 基本上都是固定的以上就是冲煞,五行,彭祖,吉凶了;