1 Star 0 Fork 10

艾伦/paipan

forked from paipan/paipan 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
lunar.js 54.93 KB
一键复制 编辑 原始数据 按行查看 历史
qtguide 提交于 2017-01-05 12:35 . gui.htm and bazi*.htm
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022
/**************************
寿星万年历中日对象的标准定义
假设日对象的数据结构为ob
·日的公历信息
ob.d0 2000.0起算儒略日,北京时12:00
ob.di 所在公历月内日序数
ob.y 所在公历年,同lun.y
ob.m 所在公历月,同lun.m
ob.d 日名称(公历)
ob.dn 所在公历月的总天数,同lun.d0
ob.week0所在月的月首的星期,同lun.w0
ob.week 星期
ob.weeki在本月中的周序号
ob.weekN本月的总周数
·日的农历信息
ob.Ldi 距农历月首的编移量,0对应初一
ob.Ldc 日名称(农历),即'初一,初二等'
ob.cur_dz 距冬至的天数
ob.cur_xz 距夏至的天数
ob.cur_lq 距立秋的天数
ob.cur_mz 距芒种的天数
ob.cur_xs 距小暑的天数
ob.Lmc 月名称
ob.Ldn 月大小
ob.Lleap闰状况(值为'闰'或空串)
ob.Lmc2 下个月名称,判断除夕时要用到
·日的农历纪年、月、日、时及星座
ob.Lyear 农历纪年(10进制,1984年起算,分界点可以是立春也可以是春节,在程序中选择一个)
ob.Lyear2 干支纪年
ob.Lmonth 纪月处理,1998年12月7日(大雪)开始连续进行节气计数,0为甲子
ob.Lmonth2 干支纪月
ob.Lday2 纪日
ob.Ltime2 纪时
ob.XiZ 星座
·日的回历信息
ob.Hyear 年(回历)
ob.Hmonth 月(回历)
ob.Hday 日(回历)
·日的其它信息
ob.yxmc 月相名称
ob.yxjd 月相时刻(儒略日)
ob.yxsj 月相时间串
ob.jqmc 节气名称
ob.jqjd 节气时刻(儒略日)
ob.jqsj 节气时间串
*****************************/
/*****************************
寿星万年历中月对象的数据结构定义
假设月对象的名称为lun
lun.w0 本月第一天的星期
lun.y 公历年份
lun.m 公历月分
lun.d0 月首的J2000.0起算的儒略日数
lun.dn 本月的天数
lun.Ly 该年的干支纪年
lun.ShX 该年的生肖
lun[0] 该月第1天(日对象)
lun[1] 该月第2天(日对象)
……
/******************************
/******************************
以下程序严格尊守以上规范,即创建的月(或日)对象,必含以上数据结构内容。寿星万年历通过Lunar类件得到月对象
月或月对象的数据结构的扩充:例如调用oba.getDayName(ob,ob),可扩展ob对象的“节日信息”,返回值在ob.A、ob.B、ob.C中
根据某些需要,用户还可以自行扩展ob
******************************/
//=============================
//公历基础构件,JD物件的补充
//public中定义的成员可以直接使用
//=============================
var oba={ //公历基础构件
//private私有成员定义
wFtv : new Array( //某月的第几个星期几,如第2个星期一指从月首开始顺序找到第2个“星期一”
'0150I世界麻风日', //一月的最后一个星期日(月倒数第一个星期日)
'0520.国际母亲节',
'0530I全国助残日',
'0630.父亲节',
'0730.被奴役国家周',
'0932I国际和平日',
'0940.国际聋人节 世界儿童日',
'0950I世界海事日',
'1011.国际住房日',
'1013I国际减轻自然灾害日(减灾日)',
'1144I感恩节'
),
sFtv : '', //假日表,由init初始化
//public公有成员定义
init:function(){ //初始化
var i;
var s = //国历节日,#表示放假日,I表示重要节日或纪念日
'01#元旦|' //1月
+'02I世界湿地日,10.国际气象节,14I情人节|' //2月
+'01.国际海豹日,03.全国爱耳日,05.1963-9999学雷锋纪念日,08I妇女节,12I植树节,12.1925-9999孙中山逝世纪念日,14.国际警察日,' //3月
+'15I1983-9999消费者权益日,17.中国国医节,17.国际航海日,21.世界森林日,21.消除种族歧视国际日,21.世界儿歌日,22I世界水日,'
+'23I世界气象日,24.1982-9999世界防治结核病日,25.全国中小学生安全教育日,30.巴勒斯坦国土日|'
+'01I1564-9999愚人节,01.全国爱国卫生运动月(四月),01.税收宣传月(四月),07I世界卫生日,22I世界地球日,23.世界图书和版权日,24.亚非新闻工作者日|' //4月
+'01#1889-9999劳动节,04I青年节,05.碘缺乏病防治日,08.世界红十字日,12I国际护士节,15I国际家庭日,17.国际电信日,18.国际博物馆日,' //5月
+'20.全国学生营养日,23.国际牛奶日,31I世界无烟日|'
+'01I1925-9999国际儿童节,05.世界环境保护日,06.全国爱眼日,17.防治荒漠化和干旱日,23.国际奥林匹克日,25.全国土地日,26I国际禁毒日|' //6月
+'01I1997-9999香港回归纪念日,01I1921-9999中共诞辰,01.世界建筑日,02.国际体育记者日,07I1937-9999抗日战争纪念日,11I世界人口日,30.非洲妇女日|' //7月
+'01I1927-9999建军节,08.中国男子节(爸爸节)|' //8月
+'03I1945-9999抗日战争胜利纪念,08.1966-9999国际扫盲日,08.国际新闻工作者日,09.毛泽东逝世纪念,10I中国教师节,14.世界清洁地球日,' //9月
+'16.国际臭氧层保护日,18I九·一八事变纪念日,20.国际爱牙日,27.世界旅游日,28I孔子诞辰|'
+'01#1949-9999国庆节,01.世界音乐日,01.国际老人节,02#1949-9999国庆节假日,02.国际和平与民主自由斗争日,03#1949-9999国庆节假日,' //10月
+'04.世界动物日,06.老人节,08.全国高血压日,08.世界视觉日,09.世界邮政日,09.万国邮联日,10I辛亥革命纪念日,10.世界精神卫生日,'
+'13.世界保健日,13.国际教师节,14.世界标准日,15.国际盲人节(白手杖节),16.世界粮食日,17.世界消除贫困日,22.世界传统医药日,24.联合国日,31.世界勤俭日|'
+'07.1917-9999十月社会主义革命纪念日,08.中国记者日,09.全国消防安全宣传教育日,10.世界青年节,11.国际科学与和平周(本日所属的一周),12.孙中山诞辰纪念日,'
+'14.世界糖尿病日,17.国际大学生节,17.世界学生节,20.彝族年,21.彝族年,21.世界问候日,21.世界电视日,22.彝族年,29.国际声援巴勒斯坦人民国际日|' //11月
+'01I1988-9999世界艾滋病日,03.世界残疾人日,05.国际经济和社会发展志愿人员日,08.国际儿童电视日,09.世界足球日,10.世界人权日,' //12月
+'12I西安事变纪念日,13I南京大屠杀(1937年)纪念日,20.澳门回归纪念,21.国际篮球日,24I平安夜,25I圣诞节,26.毛泽东诞辰纪念';
this.sFtv=s.split('|');
for(i=0;i<this.sFtv.length;i++) this.sFtv[i]=this.sFtv[i].split(',');
},
getDayName:function(u,r){ //取某日节日,传入日对象
/****************
节日名称生成
传入日物件u
返回某日节日信息
r.A 重要喜庆日子名称(可将日子名称置红)
r.B 重要日子名称
r.C 各种日子名称(连成一大串)
r.Fjia 放假日子(可用于日期数字置红)
*****************/
var m0=(u.m<10?'0':'')+u.m;
var d0=(u.d<10?'0':'')+u.d;
var i,j,s,s2,type;
if(u.week==0||u.week==6) r.Fjia = 1; //星期日或星期六放假
//按公历日期查找
for(i=0;i<this.sFtv[u.m-1].length;i++){ //公历节日或纪念日,遍历本月节日表
s=this.sFtv[u.m-1][i];
if(s.substr(0,2)!=d0) continue;
s = s.substr(2,s.length-2);
type=s.substr(0,1);
if(s.substr(5,1)=='-'){ //有年限的
if( u.y<(s.substr(1,4)-0) || u.y>(s.substr(6,4)-0) ) continue;
s = s.substr(10,s.length-10);
} else {
if(u.y<1850) continue;
s = s.substr(1,s.length-1);
}
if(type=='#') r.A += s + ' ', r.Fjia = 1; //放假的节日
if(type=='I') r.B += s + ' '; //主要
if(type=='.') r.C += s + ' '; //其它
}
//按周查找
var w=u.weeki; if(u.week>=u.week0) w+=1;
var w2=w; if(u.weeki==u.weekN-1) w2=5;
w = m0 + w + u.week; //d日在本月的第几个星期某
w2= m0 + w2 + u.week;
for(i=0;i<this.wFtv.length;i++){
s=this.wFtv[i];
s2=s.substr(0,4);
if(s2!=w && s2!=w2) continue;
type=s.substr(4,1);
s = s.substr(5,s.length-5);
if(type=='#') r.A += s + ' ', r.Fjia = 1;
if(type=='I') r.B += s +' ';
if(type=='.') r.C += s + ' ';
}
},
getHuiLi:function(d0,r){ //回历计算
//以下算法使用Excel测试得到,测试时主要关心年临界与月临界
var z,y,m,d;
d = d0 + 503105; z = int2( d/10631 ); //10631为一周期(30年)
d -= z*10631; y = int2((d+0.5)/354.366); //加0.5的作用是保证闰年正确(一周中的闰年是第2,5,7,10,13,16,18,21,24,26,29年)
d -= int2(y*354.366+0.5); m = int2((d+0.11)/29.51); //分子加0.11,分母加0.01的作用是第354或355天的的月分保持为12月(m=11)
d -= int2(m*29.5+0.5);
r.Hyear = z*30+y+1;
r.Hmonth= m+1;
r.Hday = d+1;
}
};
oba.init();
//=============================
//农历基础构件(常数、通用函数等)
//public中定义的成员可以直接使用
//=============================
var obb={ //农历基础构件
//private私有成员定义
JNB : '', //纪年表,由init初始化
//public公有成员定义
//以下几个是公有只读数据
numCn : new Array('','','','','','','','','','',''), //中文数字
Gan:new Array("","","","","","","","","",""),
Zhi:new Array("","","","","","","","","","","",""),
ShX:new Array("","","","","","","","","","","",""),
XiZ:new Array('摩羯','水瓶','双鱼','白羊','金牛','双子','巨蟹','狮子','处女','天秤','天蝎','射手'),
yxmc:new Array("","上弦","","下弦"), //月相名称表
jqmc:new Array('冬至','小寒','大寒','立春','雨水','惊蛰','春分','清明','谷雨','立夏','小满','芒种','夏至','小暑','大暑','立秋','处暑','白露','秋分','寒露','霜降','立冬','小雪','大雪'),
ymc:new Array('十一','十二','','','','','','','','','',''), //月名称,建寅
rmc:new Array('初一','初二','初三','初四','初五','初六','初七','初八','初九','初十','十一','十二','十三','十四','十五','十六','十七','十八','十九','二十','廿一','廿二','廿三','廿四','廿五','廿六','廿七','廿八','廿九','三十','卅一'),
init:function(){ //初始化
var i;
//纪年数据结构:数据用逗号分开,每7个描述一个年号,格式为:起始公元,使用年数,已用年数,朝代,朝号,皇帝,年号
var s =
'-2069,45,0,夏,禹,,禹,-2024,10,0,夏,启,,启,-2014,25,0,夏,太康,,太康,-1986,14,0,夏,仲康,,仲康,-1972,28,0,夏,相,,相,-1944,2,0,夏,后羿,,后羿,-1942,38,0,夏,寒浞,,寒浞,-1904,21,0,夏,少康,,少康,-1883,17,0,夏,杼,,杼,-1866,26,0,夏,槐,,槐,-1840,18,0,夏,芒,,芒,-1822,16,0,夏,泄,,泄,-1806,59,0,夏,不降,,不降,-1747,21,0,夏,扃,,扃,-1726,21,0,夏,廑,,廑,'
+'-1705,31,0,夏,孔甲,,孔甲,-1674,11,0,夏,皋,,皋,-1663,11,0,夏,发,,发,-1652,53,0,夏,桀,,桀,-1599,11,0,商,商太祖,汤,商汤,-1588,1,0,商,商代王,太乙,商代王,-1587,2,0,商,哀王,子胜,外丙,-1585,4,0,商,懿王,子庸,仲壬,-1581,12,0,商,太宗,子至,太甲,-1569,29,0,商,昭王,子绚,沃丁,-1540,25,0,商,宣王,子辩,太庚,-1515,17,0,商,敬王,子高,小甲,-1498,13,0,商,元王,子密,雍己,-1485,75,0,商,中宗,子伷,太戊,-1410,11,0,商,孝成王,子庄,仲丁,'
+'-1399,15,0,商,思王,子发,外壬,-1384,9,0,商,前平王,子整,河亶甲,-1375,19,0,商,穆王,子滕,祖乙,-1356,16,0,商,桓王,子旦,祖辛,-1340,5,0,商,僖王,子逾,沃甲,-1335,9,0,商,庄王,子新,祖丁,-1326,6,0,商,顷王,子更,南庚,-1320,7,0,商,悼王,子和,阳甲,-1313,42,0,商,世祖,子旬,盘庚,-1271,21,0,商,章王,子颂,小辛,-1250,1,0,商,惠王,子敛,小乙,-1249,59,0,商,高宗,子昭,武丁,-1190,2,0,商,后平王,子跃,祖庚,-1188,33,0,商,世宗,子载,祖甲,-1155,8,0,商,甲宗,子先,廪辛,'
+'-1147,1,0,商,康祖,子嚣,庚丁,-1146,35,0,商,武祖,子瞿,武乙,-1111,11,0,商,匡王,子托,文丁,-1100,26,0,商,德王,子羡,帝乙,-1074,29,0,商,纣王,子寿,帝辛,-1045,4,0,西周,武王,姬发,武王,-1041,22,0,西周,成王,姬诵,成王,-1019,25,0,西周,康王,姬钊,康王,-994,19,0,西周,昭王,姬瑕,昭王,-975,54,0,西周,穆王,姬满,穆王,-921,23,0,西周,共王,姬繄,共王,-898,8,0,西周,懿王,姬囏,懿王,-890,6,0,西周,孝王,姬辟方,孝王,-884,8,0,西周,夷王,姬燮,夷王,-876,36,0,西周,厉王,姬胡,厉王,'
+'-840,14,0,西周,厉王,姬胡,共和,-826,46,0,西周,宣王,姬静,宣王,-780,11,0,西周,幽王,姬宫湦,幽王,-769,51,0,东周,平王,姬宜臼,平王,-718,23,0,东周,桓王,姬林,桓王,-695,15,0,东周,庄王,姬佗,庄王,-680,5,0,东周,釐王,姬胡齐,釐王,-675,25,0,东周,惠王,姬阆,惠王,-650,33,0,东周,襄王,姬郑,襄王,-617,6,0,东周,顷王,姬壬臣,顷王,-611,6,0,东周,匡王,姬班,匡王,-605,21,0,东周,定王,姬瑜,定王,-584,14,0,东周,简王,姬夷,简王,-570,27,0,东周,灵王,姬泄心,灵王,-543,24,0,东周,景王,姬贵,景王,'
+'-519,1,0,东周,悼王,姬勐,悼王,-518,44,0,东周,敬王,姬匄,敬王,-474,7,0,东周,元王,姬仁,元王,-467,27,0,东周,贞定王,姬介,贞定王,-440,1,0,东周,哀王-思王,姬去疾-姬叔,哀王-思王,-439,15,0,东周,考王,姬嵬,考王,-424,24,0,东周,威烈王,姬午,威烈王,-400,26,0,东周,安王,姬骄,安王,-374,7,0,东周,烈王,姬喜,烈王,-367,48,0,东周,显王,姬扁,显王,-319,6,0,东周,慎靓王,姬定,慎靓王,-313,8,0,东周,赧王,姬延,赧王,-305,56,0,战国-秦,昭襄王,嬴则,昭襄王,-249,1,0,战国-秦,孝文王,嬴柱,孝文王,-248,3,0,战国-秦,庄襄王,嬴子楚,庄襄王,'
+'-245,25,0,秦,嬴政,嬴政,嬴政,-220,12,0,秦,始皇帝,嬴政,始皇,-208,3,0,秦,二世皇帝,嬴胡亥,二世,-205,12,0,西汉,高帝,刘邦,高帝,-193,7,0,西汉,惠帝,刘盈,惠帝,-186,8,0,西汉,高后,吕雉,高后,-178,16,0,西汉,文帝,刘恒,文帝,-162,7,0,西汉,文帝,刘恒,后元,-155,7,0,西汉,景帝,刘启,景帝,-148,6,0,西汉,景帝,刘启,中元,-142,3,0,西汉,景帝,刘启,后元,-139,6,0,西汉,武帝,刘彻,建元,-133,6,0,西汉,武帝,刘彻,元光,-127,6,0,西汉,武帝,刘彻,元朔,-121,6,0,西汉,武帝,刘彻,元狩,'
+'-115,6,0,西汉,武帝,刘彻,元鼎,-109,6,0,西汉,武帝,刘彻,元封,-103,4,0,西汉,武帝,刘彻,太初,-99,4,0,西汉,武帝,刘彻,天汉,-95,4,0,西汉,武帝,刘彻,太始,-91,4,0,西汉,武帝,刘彻,征和,-87,2,0,西汉,武帝,刘彻,后元,-85,6,0,西汉,昭帝,刘弗陵,始元,-79,6,0,西汉,昭帝,刘弗陵,元凤,-73,1,0,西汉,昭帝,刘弗陵,元平,-72,4,0,西汉,宣帝,刘询,本始,-68,4,0,西汉,宣帝,刘询,地节,-64,4,0,西汉,宣帝,刘询,元康,-60,4,0,西汉,宣帝,刘询,神爵,-56,4,0,西汉,宣帝,刘询,五凤,'
+'-52,4,0,西汉,宣帝,刘询,甘露,-48,1,0,西汉,宣帝,刘询,黄龙,-47,5,0,西汉,元帝,刘奭,初元,-42,5,0,西汉,元帝,刘奭,永光,-37,5,0,西汉,元帝,刘奭,建昭,-32,1,0,西汉,元帝,刘奭,竟宁,-31,4,0,西汉,成帝,刘骜,建始,-27,4,0,西汉,成帝,刘骜,河平,-23,4,0,西汉,成帝,刘骜,阳朔,-19,4,0,西汉,成帝,刘骜,鸿嘉,-15,4,0,西汉,成帝,刘骜,永始,-11,4,0,西汉,成帝,刘骜,元延,-7,2,0,西汉,成帝,刘骜,绥和,-5,4,0,西汉,哀帝,刘欣,建平,-1,2,0,西汉,哀帝,刘欣,元寿,'
+'1,5,0,西汉,平帝,刘衍,元始,6,2,0,西汉,孺子婴,王莽摄政,居摄,8,1,0,西汉,孺子婴,王莽摄政,初始,9,5,0,新,,王莽,始建国,14,6,0,新,,王莽,天凤,20,3,0,新,,王莽,地皇,23,2,0,西汉,更始帝,刘玄,更始,25,31,0,东汉,光武帝,刘秀,建武,56,2,0,东汉,光武帝,刘秀,建武中元,58,18,0,东汉,明帝,刘庄,永平,76,8,0,东汉,章帝,刘炟,建初,84,3,0,东汉,章帝,刘炟,元和,87,2,0,东汉,章帝,刘炟,章和,89,16,0,东汉,和帝,刘肇,永元,105,1,0,东汉,和帝,刘肇,元兴,'
+'106,1,0,东汉,殇帝,刘隆,延平,107,7,0,东汉,安帝,刘祜,永初,114,6,0,东汉,安帝,刘祜,元初,120,1,0,东汉,安帝,刘祜,永宁,121,1,0,东汉,安帝,刘祜,建光,122,4,0,东汉,安帝,刘祜,延光,126,6,0,东汉,顺帝,刘保,永建,132,4,0,东汉,顺帝,刘保,阳嘉,136,6,0,东汉,顺帝,刘保,永和,142,2,0,东汉,顺帝,刘保,汉安,144,1,0,东汉,顺帝,刘保,建康,145,1,0,东汉,冲帝,刘炳,永嘉,146,1,0,东汉,质帝,刘缵,本初,147,3,0,东汉,桓帝,刘志,建和,150,1,0,东汉,桓帝,刘志,和平,'
+'151,2,0,东汉,桓帝,刘志,元嘉,153,2,0,东汉,桓帝,刘志,永兴,155,3,0,东汉,桓帝,刘志,永寿,158,9,0,东汉,桓帝,刘志,延熹,167,1,0,东汉,桓帝,刘志,永康,168,4,0,东汉,灵帝,刘宏,建宁,172,5,0,东汉,灵帝,刘宏,熹平,178,6,0,东汉,灵帝,刘宏,光和,184,6,0,东汉,灵帝,刘宏,中平,190,4,0,东汉,献帝,刘协,初平,194,2,0,东汉,献帝,刘协,兴平,196,24,0,东汉,献帝,刘协,建安,220,7,0,三国-魏,文帝,曹丕,黄初,227,6,0,三国-魏,明帝,曹叡,太和,233,4,0,三国-魏,明帝,曹叡,青龙,'
+'237,3,0,三国-魏,明帝,曹叡,景初,240,9,0,三国-魏,齐王,曹芳,正始,249,5,0,三国-魏,齐王,曹芳,嘉平,254,2,0,三国-魏,高贵乡公,曹髦,正元,256,4,0,三国-魏,高贵乡公,曹髦,甘露,260,4,0,三国-魏,元帝,曹奂,景元,264,1,0,三国-魏,元帝,曹奂,咸熙,265,10,0,西晋,武帝,司马炎,泰始,275,5,0,西晋,武帝,司马炎,咸宁,280,10,0,西晋,武帝,司马炎,太康,290,10,0,西晋,武帝,司马炎,太熙,300,1,0,西晋,惠帝,司马衷,永康,301,1,0,西晋,惠帝,司马衷,永宁,302,2,0,西晋,惠帝,司马衷,太安,304,2,0,西晋,惠帝,司马衷,永安,'
+'306,1,0,西晋,惠帝,司马衷,光熙,307,6,0,西晋,怀帝,司马炽,永嘉,313,4,0,西晋,愍帝,司马邺,建兴,317,1,0,东晋,元帝,司马睿,建武,318,4,0,东晋,元帝,司马睿,大兴,322,1,0,东晋,元帝,司马睿,永昌,323,3,0,东晋,明帝,司马绍,太宁,326,9,0,东晋,成帝,司马衍,咸和,335,8,0,东晋,成帝,司马衍,咸康,343,2,0,东晋,康帝,司马岳,建元,345,12,0,东晋,穆帝,司马聃,永和,357,5,0,东晋,穆帝,司马聃,升平,362,1,0,东晋,哀帝,司马丕,隆和,363,3,0,东晋,哀帝,司马丕,兴宁,366,5,0,东晋,海西公,司马奕,太和,'
+'371,2,0,东晋,简文帝,司马昱,咸安,373,3,0,东晋,孝武帝,司马曜,甯康,376,21,0,东晋,孝武帝,司马曜,太元,397,5,0,东晋,安帝,司马德宗,隆安,402,3,0,东晋,安帝,司马德宗,元兴,405,14,0,东晋,安帝,司马德宗,义熙,419,1,0,东晋,恭帝,司马德文,元熙,420,3,0,南朝/宋,武帝,刘裕,永初,423,2,0,南朝/宋,少帝,刘义符,景平,424,30,0,南朝/宋,文帝,刘義隆,元嘉,454,3,0,南朝/宋,孝武,帝刘骏,孝建,457,8,0,南朝/宋,孝武,帝刘骏,大明,465,1,0,南朝/宋,废帝,刘子业,永光,465,1,0,南朝/宋,废帝,刘子业,景和,'
+'465,7,0,南朝/宋,明帝,刘彧,泰始,472,1,0,南朝/宋,明帝,刘彧,泰豫,473,5,0,南朝/宋,废帝,刘昱,元徽,477,3,0,南朝/宋,顺帝,刘准,升明,479,4,0,南朝/齐,高帝,萧道成,建元,483,11,0,南朝/齐,武帝,萧赜,永明,494,1,0,南朝/齐,欎林王,萧昭业,隆昌,494,1,0,南朝/齐,海陵王,萧昭文,延兴,494,5,0,南朝/齐,明帝,萧鸾,建武,498,1,0,南朝/齐,明帝,萧鸾,永泰,499,3,0,南朝/齐,东昏侯,萧宝,中兴,501,2,0,南朝/齐,和帝,萧宝融,中兴,502,18,0,南朝/梁,武帝,萧衍,天监,520,8,0,南朝/梁,武帝,萧衍,普通,527,3,0,南朝/梁,武帝,萧衍,大通,'
+'529,6,0,南朝/梁,武帝,萧衍,中大通,535,12,0,南朝/梁,武帝,萧衍,大同,546,2,0,南朝/梁,武帝,萧衍,中大同,547,3,0,南朝/梁,武帝,萧衍,太清,550,2,0,南朝/梁,简文帝,萧纲,大宝,551,2,0,南朝/梁,豫章王,萧栋,天正,552,4,0,南朝/梁,元帝,萧绎,承圣,555,1,0,南朝/梁,贞阳侯,萧渊明,天成,555,2,0,南朝/梁,敬帝,萧方智,绍泰,556,2,0,南朝/梁,敬帝,萧方智,太平,557,3,0,南朝/陈,武帝,陈霸先,太平,560,7,0,南朝/陈,文帝,陈蒨,天嘉,566,1,0,南朝/陈,文帝,陈蒨,天康,567,2,0,南朝/陈,废帝,陈伯宗,光大,569,14,0,南朝/陈,宣帝,陈顼,太建,'
+'583,4,0,南朝/陈,后主,陈叔宝,至德,587,3,0,南朝/陈,后主,陈叔宝,祯明,555,8,0,南朝/后梁,宣帝,萧詧,大定,562,24,0,南朝/后梁,明帝,萧岿,天保,586,2,0,南朝/后梁,莒公,萧琮,广运,386,11,0,北朝/北魏,道武帝,拓跋圭,登国,396,3,0,北朝/北魏,道武帝,拓跋圭,皇始,398,7,0,北朝/北魏,道武帝,拓跋圭,天兴,404,6,0,北朝/北魏,道武帝,拓跋圭,天赐,409,5,0,北朝/北魏,明元帝,拓跋嗣,永兴,414,3,0,北朝/北魏,明元帝,拓跋嗣,神瑞,416,8,0,北朝/北魏,明元帝,拓跋嗣,泰常,424,5,0,北朝/北魏,太武帝,拓跋焘,始光,428,4,0,北朝/北魏,太武帝,拓跋焘,神麚,432,3,0,北朝/北魏,太武帝,拓跋焘,延和,'
+'435,6,0,北朝/北魏,太武帝,拓跋焘,太延,440,12,0,北朝/北魏,太武帝,拓跋焘,太平真君,451,2,0,北朝/北魏,太武帝,拓跋焘,正平,452,1,0,北朝/北魏,南安王,拓跋余,承平,452,3,0,北朝/北魏,文成帝,拓跋浚,兴安,454,2,0,北朝/北魏,文成帝,拓跋浚,兴光,455,5,0,北朝/北魏,文成帝,拓跋浚,太安,460,6,0,北朝/北魏,文成帝,拓跋浚,和平,466,2,0,北朝/北魏,献文帝,拓跋弘,天安,467,5,0,北朝/北魏,献文帝,拓跋弘,皇兴,471,6,0,北朝/北魏,教文帝,拓跋宏,延兴,476,1,0,北朝/北魏,孝文帝,拓跋宏,承明,477,23,0,北朝/北魏,孝文帝,拓跋宏,太和,500,4,0,北朝/北魏,宣武帝,元恪,景明,504,5,0,北朝/北魏,宣武帝,元恪,正始,'
+'508,5,0,北朝/北魏,宣武帝,元恪,永平,512,4,0,北朝/北魏,宣武帝,元恪,延昌,516,3,0,北朝/北魏,孝明帝,元诩,熙平,518,3,0,北朝/北魏,孝明帝,元诩,神龟,520,6,0,北朝/北魏,孝明帝,元诩,正光,525,3,0,北朝/北魏,孝明帝,元诩,孝昌,528,1,0,北朝/北魏,孝明帝,元诩,武泰,528,1,0,北朝/北魏,孝庄帝,元子攸,建义,528,3,0,北朝/北魏,孝庄帝,元子攸,永安,530,2,0,北朝/北魏,东海王,元晔,建明,531,2,0,北朝/北魏,节闵帝,元恭,普泰,531,2,0,北朝/北魏,安定王,元朗,中兴,532,1,0,北朝/北魏,孝武帝,元修,太昌,532,1,0,北朝/北魏,孝武帝,元修,永兴,532,3,0,北朝/北魏,孝武帝,元修,永熙,'
+'534,4,0,北朝/东魏,孝静帝,元善见,天平,538,2,0,北朝/东魏,孝静帝,元善见,元象,539,4,0,北朝/东魏,孝静帝,元善见,兴和,543,8,0,北朝/东魏,孝静帝,元善见,武定,535,17,0,北朝/西魏,文帝,元宝炬,大统,552,3,0,北朝/西魏,废帝,元钦,大统,554,3,0,北朝/西魏,恭帝,元廓,大统,550,10,0,北朝/北齐,文宣帝,高洋,天保,560,1,0,北朝/北齐,废帝,高殷,乾明,560,2,0,北朝/北齐,孝昭帝,高演,皇建,561,2,0,北朝/北齐,武成帝,高湛,太宁,562,4,0,北朝/北齐,武成帝,高湛,河清,565,5,0,北朝/北齐,温公,高纬,天统,570,7,0,北朝/北齐,温公,高纬,武平,576,2,0,北朝/北齐,温公,高纬,隆化,'
+'576,1,0,北朝/北齐,安德王,高延宗,德昌,577,1,0,北朝/北齐,幼主,高恒,承光,557,1,0,北朝/北周,闵帝,宇文觉,空,557,2,0,北朝/北周,明帝,宇文毓,空,559,2,0,北朝/北周,明帝,宇文毓,武成,561,5,0,北朝/北周,武帝,宇文邕,保定,566,7,0,北朝/北周,武帝,宇文邕,天和,572,7,0,北朝/北周,武帝,宇文邕,建德,578,1,0,北朝/北周,武帝,宇文邕,宣政,579,1,0,北朝/北周,宣帝,宇文贇,大成,579,2,0,北朝/北周,静帝,宇文衍,大象,581,1,0,北朝/北周,静帝,宇文衍,大定,581,20,0,隋,文帝,杨坚,开皇,601,4,0,隋,文帝,杨坚,仁寿,605,13,0,隋,炀帝,杨广,大业,'
+'617,2,0,隋,恭帝,杨侑,义宁,618,9,0,唐,高祖,李渊,武德,627,23,0,唐,太宗,李世民,贞观,650,6,0,唐,高宗,李治,永徽,656,6,0,唐,高宗,李治,显庆,661,3,0,唐,高宗,李治,龙朔,664,2,0,唐,高宗,李治,麟德,666,3,0,唐,高宗,李治,乾封,668,3,0,唐,高宗,李治,总章,670,5,0,唐,高宗,李治,咸亨,674,3,0,唐,高宗,李治,上元,676,4,0,唐,高宗,李治,仪凤,679,2,0,唐,高宗,李治,调露,680,2,0,唐,高宗,李治,永隆,681,2,0,唐,高宗,李治,开耀,'
+'682,2,0,唐,高宗,李治,永淳,683,1,0,唐,高宗,李治,弘道,684,1,0,唐,中宗,李显,嗣圣,684,1,0,唐,睿宗,李旦,文明,684,1,0,武周,则天后,武曌,光宅,685,4,0,武周,则天后,武曌,垂拱,689,1,0,武周,则天后,武曌,永昌,689,2,0,武周,则天后,武曌,载初,690,3,0,武周,则天后,武曌,天授,692,1,0,武周,则天后,武曌,如意,692,3,0,武周,则天后,武曌,长寿,694,1,0,武周,则天后,武曌,延载,695,1,0,武周,则天后,武曌,证圣,695,2,0,武周,则天后,武曌,天册万岁,696,1,0,武周,则天后,武曌,万岁登封,'
+'696,2,0,武周,则天后,武曌,万岁通天,697,1,0,武周,则天后,武曌,神功,698,3,0,武周,则天后,武曌,圣历,700,1,0,武周,则天后,武曌,久视,701,1,0,武周,则天后,武曌,大足,701,4,0,武周,则天后,武曌,长安,705,1,0,武周,则天后,李显,神龙,705,2,0,唐,中宗,李显,神龙,707,4,0,唐,中宗,李显,景龙,710,1,0,唐,温王,李重茂,唐隆,710,2,0,唐,睿宗,李旦,景云,712,1,0,唐,睿宗,李旦,太极,712,1,0,唐,睿宗,李旦,延和,712,2,0,唐,玄宗,李隆基,先天,713,29,0,唐,玄宗,李隆基,开元,'
+'742,15,0,唐,玄宗,李隆基,天宝,756,3,0,唐,肃宗,李亨,至德,758,3,0,唐,肃宗,李亨,乾元,760,3,0,唐,肃宗,李亨,上元,762,2,0,唐,肃宗,李亨,宝应,763,2,0,唐,代宗,李豫,广德,765,2,0,唐,肃宗,李亨,永泰,766,14,0,唐,肃宗,李亨,大历,780,4,0,唐,德宗,李适,建中,784,1,0,唐,德宗,李适,兴元,785,21,0,唐,德宗,李适,贞元,805,1,0,唐,顺宗,李诵,永贞,806,15,0,唐,宪宗,李纯,元和,821,4,0,唐,穆宗,李恒,长庆,825,3,0,唐,敬宗,李湛,宝历,'
+'827,9,0,唐,文宗,李昂,大和,836,5,0,唐,文宗,李昂,开成,841,6,0,唐,武宗,李炎,会昌,847,14,0,唐,宣宗,李忱,大中,860,15,0,唐,宣宗,李忱,咸通,874,6,0,唐,僖宗,李儇,乾符,880,2,0,唐,僖宗,李儇,广明,881,5,0,唐,僖宗,李儇,中和,885,4,0,唐,僖宗,李儇,光启,888,1,0,唐,僖宗,李儇,文德,889,1,0,唐,昭宗,李晔,龙纪,890,2,0,唐,昭宗,李晔,大顺,892,2,0,唐,昭宗,李晔,景福,894,5,0,唐,昭宗,李晔,乾宁,898,4,0,唐,昭宗,李晔,光化,'
+'901,4,0,唐,昭宗,李晔,天复,904,1,0,唐,昭宗,李晔,天佑,905,3,1,唐,昭宣帝,李祝,天佑,907,5,0,五代/梁,太祖,朱温,开平,911,2,0,五代/梁,太祖,朱温,乾化,913,1,0,五代/梁,庶人,朱友圭,凤历,913,3,2,五代/梁,末帝,朱友贞,乾化,915,7,0,五代/梁,末帝,朱友贞,贞明,921,3,0,五代/梁,末帝,朱友贞,龙德,923,4,0,五代/唐,庄宗,李存勗,同光,926,5,0,五代/唐,明宗,李嗣源,天成,930,4,0,五代/唐,明宗,李嗣源,长兴,934,1,0,五代/唐,闵帝,李从厚,应顺,934,3,0,五代/唐,潞王,李从珂,清泰,936,6,0,五代/晋,高祖,石敬瑭,天福,'
+'942,2,6,五代/晋,出帝,石重贵,天福,944,3,0,五代/晋,出帝,石重贵,开运,947,12,0,五代/汉,高祖,刘知远,天福,948,1,0,五代/汉,隐帝,刘承祐,乾祐,948,3,0,五代/汉,隐帝,刘承祐,乾祐,951,3,0,五代/周,太祖,郭威,广顺,954,1,0,五代/周,太祖,郭威,显德,954,6,0,五代/周,世宗,柴荣,显德,959,2,5,五代/周,恭帝,郭宗训,显德,960,4,0,北宋,太祖,赵匡胤,建隆,963,6,0,北宋,太祖,赵匡胤,乾德,968,9,0,北宋,太祖,赵匡胤,开宝,976,9,0,北宋,太宗,赵炅,太平兴国,984,4,0,北宋,太宗,赵炅,雍熙,988,2,0,北宋,太宗,赵炅,端拱,'
+'990,5,0,北宋,太宗,赵炅,淳化,995,3,0,北宋,太宗,赵炅,至道,998,6,0,北宋,真宗,赵恒,咸平,1004,4,0,北宋,真宗,赵恒,景德,1008,9,0,北宋,真宗,赵恒,大中祥符,1017,5,0,北宋,真宗,赵恒,天禧,1022,1,0,北宋,真宗,赵恒,乾兴,1023,10,0,北宋,仁宗,赵祯,天圣,1032,2,0,北宋,仁宗,赵祯,明道,1034,5,0,北宋,仁宗,赵祯,景祐,1038,3,0,北宋,仁宗,赵祯,宝元,1040,2,0,北宋,仁宗,赵祯,康定,1041,8,0,北宋,仁宗,赵祯,庆历,1049,6,0,北宋,仁宗,赵祯,皇祐,1054,3,0,北宋,仁宗,赵祯,至和,'
+'1056,8,0,北宋,仁宗,赵祯,嘉祐,1064,4,0,北宋,英宗,赵曙,治平,1068,10,0,北宋,神宗,赵顼,熙宁,1078,8,0,北宋,神宗,赵顼,元丰,1086,9,0,北宋,哲宗,赵煦,元祐,1094,5,0,北宋,哲宗,赵煦,绍圣,1098,3,0,北宋,哲宗,赵煦,元符,1101,1,0,北宋,徽宗,赵佶,建中靖国,1102,5,0,北宋,徽宗,赵佶,崇宁,1107,4,0,北宋,徽宗,赵佶,大观,1111,8,0,北宋,徽宗,赵佶,政和,1118,2,0,北宋,徽宗,赵佶,重和,1119,7,0,北宋,徽宗,赵佶,宣和,1126,2,0,北宋,钦宗,赵桓,靖康,1127,4,0,南宋,高宗,赵构,建炎,'
+'1131,32,0,南宋,高宗,赵构,绍兴,1163,2,0,南宋,孝宗,赵慎,隆兴,1165,9,0,南宋,孝宗,赵慎,乾道,1174,16,0,南宋,孝宗,赵慎,淳熙,1190,5,0,南宋,光宗,赵暴,绍熙,1195,6,0,南宋,宁宗,赵扩,庆元,1201,4,0,南宋,宁宗,赵扩,嘉泰,1205,3,0,南宋,宁宗,赵扩,开禧,1208,17,0,南宋,宁宗,赵扩,嘉定,1225,3,0,南宋,理宗,赵昀,宝庆,1228,6,0,南宋,理宗,赵昀,绍定,1234,3,0,南宋,理宗,赵昀,端平,1237,4,0,南宋,理宗,赵昀,嘉熙,1241,12,0,南宋,理宗,赵昀,淳祐,1253,6,0,南宋,理宗,赵昀,寶祐,'
+'1259,1,0,南宋,理宗,赵昀,开庆,1260,5,0,南宋,理宗,赵昀,景定,1265,10,0,南宋,度宗,赵禥,咸淳,1275,2,0,南宋,恭宗,赵(上“日”下“丝”),德祐 ,1276,3,0,南宋,端宗,赵(上“日”下“正”),景炎,1278,2,0,南宋,帝昺,赵昺,祥兴,1271,24,7,元,世祖,孛儿只斤·忽必烈,至元,1295,3,0,元,成宗,孛儿只斤·铁穆耳,元贞,1297,11,0,元,成宗,孛儿只斤·铁穆耳,大德,1308,4,0,元,武宗,孛儿只斤·海山,至大,1312,2,0,元,仁宗,孛儿只斤·爱育黎拔力八达,皇庆,1314,7,0,元,仁宗,孛儿只斤·愛育黎拔力八達,延祐,1321,3,0,元,英宗,孛儿只斤·宗硕德八剌,至治,1324,5,0,元,泰定帝,孛儿只斤·也孙铁木耳,泰定,1328,1,0,元,泰定帝,孛儿只斤·也孙铁木耳,至和,'
+'1328,1,0,元,幼主,孛儿只斤·阿速吉八,天顺,1328,3,0,元,文宗,孛儿只斤·图贴睦尔,天历,1330,3,0,元,文宗,孛儿只斤·图贴睦尔,至顺,1333,3,0,元,惠宗,孛儿只斤·妥镤贴睦尔,元统,1335,6,0,元,惠宗,孛儿只斤·妥镤贴睦尔,至元,1341,28,0,元,惠宗,孛儿只斤·妥镤贴睦尔,至正,1368,31,0,明,太祖,朱元璋,洪武,1399,4,0,明,惠帝,朱允溫,建文,1403,22,0,明,成祖,朱棣,永乐,1425,1,0,明,仁宗,朱高炽,洪熙,1426,10,0,明,宣宗,朱瞻基,宣德,1436,14,0,明,英宗,朱祁镇,正统,1450,7,0,明,代宗,朱祁钰,景泰,1457,8,0,明,英宗,朱祁镇,天顺,1465,23,0,明,宪宗,朱见深,成化,'
+'1488,18,0,明,孝宗,朱祐樘,弘治,1506,16,0,明,武宗,朱厚照,正德,1522,45,0,明,世宗,朱厚熜,嘉靖,1567,6,0,明,穆宗,朱载贺,隆庆,1573,48,0,明,神宗,朱翊钧,万历,1620,1,0,明,光宗,朱常洛,泰昌,1621,7,0,明,熹宗,朱同校,天启,1628,17,0,明,毅宗,朱由检,崇祯,1644,18,0,清,世祖,爱新觉罗福临,顺治,1662,61,0,清,圣祖,爱新觉罗玄烨,康熙,1723,13,0,清,世宗,爱新觉罗胤禛,雍正,1736,60,0,清,高宗,爱新觉罗弘历,乾隆,1796,25,0,清,仁宗,爱新觉罗颙琰,嘉庆,1821,30,0,清,宣宗,爱新觉罗旻宁,道光,1851,11,0,清,文宗,爱新觉罗奕詝,咸丰,'
+'1862,13,0,清,穆宗,爱新觉罗载淳,同治,1875,34,0,清,德宗,爱新觉罗载湉,光绪,1909,3,0,清,无朝,爱新觉罗溥仪,宣统,1912,37,0,近、现代,中华民国,,民国,1949,9999,1948,当代,中国,,公历纪元';
this.JNB = s.split(',');
for(i=0;i<this.JNB.length;i+=7) { this.JNB[i]-=0; this.JNB[i+1]-=0; this.JNB[i+2]-=0; }
},
getNH:function(y){ //取年号
var i,j,c,s='', ob=this.JNB;
for(i=0;i<ob.length;i+=7){
j = ob[i];
if( y<j || y>=j+ob[i+1] ) continue;
c = ob[i+6] + (y-j+1+ob[i+2]) +''; //年号及年次
s += (s?';':'') + '['+ob[i+3]+']'+ob[i+4]+' '+ob[i+5]+' '+c; //i为年号元年,i+3朝代,i+4朝号,i+5皇帝,i+6年号
}
return s;
},
getDayName:function(u,r){ //计算农历节日
//按农历日期查找重量点节假日
var d=u.Lmc + (u.Lmc.length<2?'':'') + u.Ldc;
if(u.Lleap!=''){
if(d=='正月初一') r.A += '春节 ', r.Fjia = 1; //Fjia(放假)
if(d=='正月初二') r.B += '大年初二 ', r.Fjia = 1;
if(d=='五月初五') r.A += '端午节 ', r.Fjia = 1;
if(d=='八月十五') r.A += '中秋节 ', r.Fjia = 1;
if(d=='正月十五') r.A += '元宵节 ',r.B += '上元节 ', r.C += '壮族歌墟节 苗族踩山节 达斡尔族卡钦 ';
if(d=='正月十六') r.C += '侗族芦笙节(至正月二十) ';
if(d=='正月廿五') r.C += '填仓节 ';
if(d=='正月廿九') r.C += '送穷日 ';
if(d=='二月初一') r.C += '瑶族忌鸟节 ';
if(d=='二月初二') r.B += '春龙节(龙抬头) ', r.C += '畲族会亲节 ';
if(d=='二月初八') r.C += '傈傈族刀杆节 ';
if(d=='三月初三') r.B += '北帝诞 ', r.C += '苗族黎族歌墟节 ';
if(d=='三月十五') r.C += '白族三月街(至三月二十) ';
if(d=='三月廿三') r.B += '天后诞 妈祖诞 ';
if(d=='四月初八') r.B += '牛王诞 ';
if(d=='四月十八') r.C += '锡伯族西迁节 ';
if(d=='五月十三') r.B += '关帝诞 ', r.C += '阿昌族泼水节 ';
if(d=='五月廿二') r.C += '鄂温克族米阔鲁节 ';
if(d=='五月廿九') r.C += '瑶族达努节 ';
if(d=='六月初六') r.B += '姑姑节 天贶节 ', r.C += '壮族祭田节 瑶族尝新节 ';
if(d=='六月廿四') r.C += '火把节、星回节(彝、白、佤、阿昌、纳西、基诺族 ) ';
if(d=='七月初七') r.B += '七夕(中国情人节,乞巧节,女儿节 ) ';
if(d=='七月十三') r.C += '侗族吃新节 ';
if(d=='七月十五') r.B += '中元节 鬼节';
if(d=='九月初九') r.B += '重阳节 ';
if(d=='十月初一') r.B += '祭祖节(十月朝) ';
if(d=='十月十五') r.B += '下元节 ';
if(d=='十月十六') r.C += '瑶族盘王节 ';
if(d=='十二初八') r.B += '腊八节 ';
}
if(u.Lmc2==''){ //最后一月
if(d=='十二三十' && u.Ldn==30) r.A += '除夕 ',r.Fjia = 1;
if(d=='十二廿九' && u.Ldn==29) r.A += '除夕 ',r.Fjia = 1;
if(d=='十二廿三') r.B += '小年 ';
}
if(u.Ljq){
if(u.Ljq=="清明") r.A += u.Ljq+' ', r.Fjia = 1;
else r.B += u.Ljq+' ';
}
//农历杂节
var w,w2;
if(u.cur_dz>=0 && u.cur_dz<81){ //数九
w = obb.numCn[Math.floor(u.cur_dz/9)+1];
if(u.cur_dz%9==0) r.B += ''+ w +'九』 ';
else r.C += w + '九第'+(u.cur_dz%9+1)+'';
}
w = u.Lday2.substr(0,1);
w2= u.Lday2.substr(1,1);
if(u.cur_xz>=20 && u.cur_xz<30 && w=='') r.B += '初伏 ';
if(u.cur_xz>=30 && u.cur_xz<40 && w=='') r.B += '中伏 ';
if(u.cur_lq>=0 && u.cur_lq<10 && w=='') r.B += '末伏 ';
if(u.cur_mz>=0 && u.cur_mz<10 && w=='') r.B += '入梅 ';
if(u.cur_xs>=0 && u.cur_xs<12 &&w2=='') r.B += '出梅 ';
},
mingLiBaZi:function(jd,J,ob){ //命理八字计算。jd为格林尼治UT(J2000起算),J为本地经度,返回在物件ob中
var i, c, v;
var jd2 = jd+dt_T(jd); //力学时
var w = XL.S_aLon( jd2/36525, -1 ); //此刻太阳视黄经
var k = int2( (w/pi2*360+45+15*360)/30 ); //1984年立春起算的节气数(不含中气)
jd += pty_zty2(jd2/36525)+J/Math.PI/2; //本地真太阳时(使用低精度算法计算时差)
ob.bz_zty = JD.timeStr(jd);
jd += 13/24; //转为前一日23点起算(原jd为本日中午12点起算)
var D = Math.floor(jd), SC = int2( (jd-D)*12 ); //日数与时辰
v = int2(k/12+6000000); ob.bz_jn = this.Gan[v%10]+this.Zhi[v%12];
v = k+2+60000000; ob.bz_jy = this.Gan[v%10]+this.Zhi[v%12];
v = D - 6 + 9000000; ob.bz_jr = this.Gan[v%10]+this.Zhi[v%12];
v = (D-1)*12+90000000+SC;ob.bz_js = this.Gan[v%10]+this.Zhi[v%12];
v-= SC, ob.bz_JS = ''; //全天纪时表
for(i=0; i<13; i++){ //一天中包含有13个纪时
c = this.Gan[(v+i)%10]+this.Zhi[(v+i)%12]; //各时辰的八字
if(SC==i) ob.bz_js=c, c = '<font color=red>'+c+'</font>'; //红色显示这时辰
ob.bz_JS += (i?' ':'') + c;
}
},
qi_accurate : function(W) { var t=XL.S_aLon_t(W)*36525; return t - dt_T(t) + 8/24; }, //精气
so_accurate : function(W) { var t=XL.MS_aLon_t(W)*36525; return t - dt_T(t) + 8/24; }, //精朔
qi_accurate2: function(jd) { //精气
var d = Math.PI/12;
var w=Math.floor((jd+293)/365.2422*24) * d;
var a= this.qi_accurate ( w );
if(a-jd>5 ) return this.qi_accurate ( w-d );
if(a-jd<-5) return this.qi_accurate ( w+d );
return a;
},
so_accurate2: function(jd) { return this.so_accurate ( Math.floor((jd+8)/29.5306) * Math.PI*2 ); } //精朔
};
obb.init();
/************************
实气实朔计算器
适用范围 -722年2月22日——1959年12月
平气平朔计算使用古历参数进行计算
定朔、定气计算使用开普勒椭圆轨道计算,同时考虑了光行差和力学时与UT1的时间差
古代历算仅在晚期才使用开普勒方法计算,此前多采用一些修正表并插值得到,精度很低,与本程序中
的开普勒方法存在误差,造成朔日计算错误1千多个,这些错误使用一个修正表进行订正。同样,定气部分
也使用了相同的方法时行订正。
平气朔表的算法(线性拟合):
气朔日期计算公式:D = k*n + b , 式中n=0,1,2,3,...,N-1, N为该式适用的范围
h表示k不变b允许的误差,如果b不变则k许可误差为h/N
每行第1个参数为k,第2参数为b
public中定义的成员可以直接使用
*************************/
var SSQ={ //实朔实气计算器
//private成员定义
SB:'', //朔修正表
QB:'', //气修正表
suoKB : new Array( //朔直线拟合参数
1457698.231017,29.53067166, // -721-12-17 h=0.00032 古历·春秋
1546082.512234,29.53085106, // -479-12-11 h=0.00053 古历·战国
1640640.735300,29.53060000, // -221-10-31 h=0.01010 古历·秦汉
1642472.151543,29.53085439, // -216-11-04 h=0.00040 古历·秦汉
1683430.509300,29.53086148, // -104-12-25 h=0.00313 汉书·律历志(太初历)平气平朔
1752148.041079,29.53085097, // 85-02-13 h=0.00049 后汉书·律历志(四分历)
1807665.420323,29.53059851, // 237-02-12 h=0.00033 晋书·律历志(景初历)
1883618.114100,29.53060000, // 445-01-24 h=0.00030 宋书·律历志(何承天元嘉历)
1907360.704700,29.53060000, // 510-01-26 h=0.00030 宋书·律历志(祖冲之大明历)
1936596.224900,29.53060000, // 590-02-10 h=0.01010 随书·律历志(开皇历)
1939135.675300,29.53060000, // 597-01-24 h=0.00890 随书·律历志(大业历)
1947168.00// 619-01-21
),
qiKB : new Array( //气直线拟合参数
1640650.479938,15.21842500, // -221-11-09 h=0.01709 古历·秦汉
1642476.703182,15.21874996, // -216-11-09 h=0.01557 古历·秦汉
1683430.515601,15.218750011, // -104-12-25 h=0.01560 汉书·律历志(太初历)平气平朔 回归年=365.25000
1752157.640664,15.218749978, // 85-02-23 h=0.01559 后汉书·律历志(四分历) 回归年=365.25000
1807675.003759,15.218620279, // 237-02-22 h=0.00010 晋书·律历志(景初历) 回归年=365.24689
1883627.765182,15.218612292, // 445-02-03 h=0.00026 宋书·律历志(何承天元嘉历) 回归年=365.24670
1907369.128100,15.218449176, // 510-02-03 h=0.00027 宋书·律历志(祖冲之大明历) 回归年=365.24278
1936603.140413,15.218425000, // 590-02-17 h=0.00149 随书·律历志(开皇历) 回归年=365.24220
1939145.524180,15.218466998, // 597-02-03 h=0.00121 随书·律历志(大业历) 回归年=365.24321
1947180.798300,15.218524844, // 619-02-03 h=0.00052 新唐书·历志(戊寅元历)平气定朔 回归年=365.24460
1964362.041824,15.218533526, // 666-02-17 h=0.00059 新唐书·历志(麟德历) 回归年=365.24480
1987372.340971,15.218513908, // 729-02-16 h=0.00096 新唐书·历志(大衍历,至德历) 回归年=365.24433
1999653.819126,15.218530782, // 762-10-03 h=0.00093 新唐书·历志(五纪历) 回归年=365.24474
2007445.469786,15.218535181, // 784-02-01 h=0.00059 新唐书·历志(正元历,观象历) 回归年=365.24484
2021324.917146,15.218526248, // 822-02-01 h=0.00022 新唐书·历志(宣明历) 回归年=365.24463
2047257.232342,15.218519654, // 893-01-31 h=0.00015 新唐书·历志(崇玄历) 回归年=365.24447
2070282.898213,15.218425000, // 956-02-16 h=0.00149 旧五代·历志(钦天历) 回归年=365.24220
2073204.872850,15.218515221, // 964-02-16 h=0.00166 宋史·律历志(应天历) 回归年=365.24437
2080144.500926,15.218530782, // 983-02-16 h=0.00093 宋史·律历志(乾元历) 回归年=365.24474
2086703.688963,15.218523776, // 1001-01-31 h=0.00067 宋史·律历志(仪天历,崇天历) 回归年=365.24457
2110033.182763,15.218425000, // 1064-12-15 h=0.00669 宋史·律历志(明天历) 回归年=365.24220
2111190.300888,15.218425000, // 1068-02-15 h=0.00149 宋史·律历志(崇天历) 回归年=365.24220
2113731.271005,15.218515671, // 1075-01-30 h=0.00038 李锐补修(奉元历) 回归年=365.24438
2120670.840263,15.218425000, // 1094-01-30 h=0.00149 宋史·律历志 回归年=365.24220
2123973.309063,15.218425000, // 1103-02-14 h=0.00669 李锐补修(占天历) 回归年=365.24220
2125068.997336,15.218477932, // 1106-02-14 h=0.00056 宋史·律历志(纪元历) 回归年=365.24347
2136026.312633,15.218472436, // 1136-02-14 h=0.00088 宋史·律历志(统元历,乾道历,淳熙历) 回归年=365.24334
2156099.495538,15.218425000, // 1191-01-29 h=0.00149 宋史·律历志(会元历) 回归年=365.24220
2159021.324663,15.218425000, // 1199-01-29 h=0.00149 宋史·律历志(统天历) 回归年=365.24220
2162308.575254,15.218461742, // 1208-01-30 h=0.00146 宋史·律历志(开禧历) 回归年=365.24308
2178485.706538,15.218425000, // 1252-05-15 h=0.04606 淳祐历 回归年=365.24220
2178759.662849,15.218445786, // 1253-02-13 h=0.00231 会天历 回归年=365.24270
2185334.020800,15.218425000, // 1271-02-13 h=0.00520 宋史·律历志(成天历) 回归年=365.24220
2187525.481425,15.218425000, // 1277-02-12 h=0.00520 本天历 回归年=365.24220
2188621.191481,15.218437494, // 1280-02-13 h=0.00015 元史·历志(郭守敬授时历) 回归年=365.24250
2322147.76// 1645-09-21
),
so_low:function(W){ //低精度定朔计算,在2000年至600,误差在2小时以内(仍比古代日历精准很多)
var v = 7771.37714500204;
var t = ( W + 1.08472 )/v, L;
t -= ( -0.0000331*t*t
+ 0.10976 *Math.cos( 0.785 + 8328.6914*t)
+ 0.02224 *Math.cos( 0.187 + 7214.0629*t)
- 0.03342 *Math.cos( 4.669 + 628.3076*t ) )/v
+ (32*(t+1.8)*(t+1.8)-20)/86400/36525;
return t*36525 + 8/24;
},
qi_low:function(W){ //最大误差小于30分钟,平均5分
var t,L,v= 628.3319653318;
t = ( W - 4.895062166 )/v; //第一次估算,误差2天以内
t -= ( 53*t*t + 334116*Math.cos( 4.67+628.307585*t) + 2061*Math.cos( 2.678+628.3076*t)*t )/v/10000000; //第二次估算,误差2小时以内
L = 48950621.66 + 6283319653.318*t + 53*t*t //平黄经
+334166 * Math.cos( 4.669257+ 628.307585*t) //地球椭圆轨道级数展开
+3489 * Math.cos( 4.6261 + 1256.61517*t ) //地球椭圆轨道级数展开
+2060.6 * Math.cos( 2.67823 + 628.307585*t ) * t //一次泊松项
- 994 - 834*Math.sin(2.1824-33.75705*t); //光行差与章动修正
t -= (L/10000000 -W )/628.332 + (32*(t+1.8)*(t+1.8)-20)/86400/36525;
return t*36525 + 8/24;
},
qi_high:function(W){ //较高精度气
var t = XL.S_aLon_t2(W)*36525;
t = t - dt_T(t)+8/24;
var v = ( (t+0.5) %1 ) * 86400;
if(v<1200 || v >86400-1200) t = XL.S_aLon_t(W)*36525 - dt_T(t)+8/24;
return t;
},
so_high:function(W){ //较高精度朔
var t = XL.MS_aLon_t2(W)*36525;
t = t - dt_T(t)+8/24;
var v = ( (t+0.5) %1 ) * 86400;
if(v<1800 || v >86400-1800) t = XL.MS_aLon_t(W)*36525 - dt_T(t)+8/24;
return t;
},
jieya:function(s){ //气朔解压缩
var o="0000000000",o2=o+o;
s=s.replace(/J/g,'00');
s=s.replace(/I/g,'000');
s=s.replace(/H/g,'0000');
s=s.replace(/G/g,'00000');
s=s.replace(/t/g,'02');
s=s.replace(/s/g,'002');
s=s.replace(/r/g,'0002');
s=s.replace(/q/g,'00002');
s=s.replace(/p/g,'000002');
s=s.replace(/o/g,'0000002');
s=s.replace(/n/g,'00000002');
s=s.replace(/m/g,'000000002');
s=s.replace(/l/g,'0000000002');
s=s.replace(/k/g,'01');
s=s.replace(/j/g,'0101');
s=s.replace(/i/g,'001');
s=s.replace(/h/g,'001001');
s=s.replace(/g/g,'0001');
s=s.replace(/f/g,'00001');
s=s.replace(/e/g,'000001');
s=s.replace(/d/g,'0000001');
s=s.replace(/c/g,'00000001');
s=s.replace(/b/g,'000000001');
s=s.replace(/a/g,'0000000001');
s=s.replace(/A/g,o2+o2+o2);
s=s.replace(/B/g,o2+o2+o);
s=s.replace(/C/g,o2+o2);
s=s.replace(/D/g,o2+o);
s=s.replace(/E/g,o2);
s=s.replace(/F/g,o);
return s;
},
init:function(){ //初使用化
var suoS,qiS;
// 619-01-21开始16598个朔日修正表 d0=1947168
suoS ="EqoFscDcrFpmEsF2DfFideFelFpFfFfFiaipqti1ksttikptikqckstekqttgkqttgkqteksttikptikq2fjstgjqttjkqttgkqt";
suoS+="ekstfkptikq2tijstgjiFkirFsAeACoFsiDaDiADc1AFbBfgdfikijFifegF1FhaikgFag1E2btaieeibggiffdeigFfqDfaiBkF";
suoS+="1kEaikhkigeidhhdiegcFfakF1ggkidbiaedksaFffckekidhhdhdikcikiakicjF1deedFhFccgicdekgiFbiaikcfi1kbFibef";
suoS+="gEgFdcFkFeFkdcfkF1kfkcickEiFkDacFiEfbiaejcFfffkhkdgkaiei1ehigikhdFikfckF1dhhdikcfgjikhfjicjicgiehdik";
suoS+="cikggcifgiejF1jkieFhegikggcikFegiegkfjebhigikggcikdgkaFkijcfkcikfkcifikiggkaeeigefkcdfcfkhkdgkegieid";
suoS+="hijcFfakhfgeidieidiegikhfkfckfcjbdehdikggikgkfkicjicjF1dbidikFiggcifgiejkiegkigcdiegfggcikdbgfgefjF1";
suoS+="kfegikggcikdgFkeeijcfkcikfkekcikdgkabhkFikaffcfkhkdgkegbiaekfkiakicjhfgqdq2fkiakgkfkhfkfcjiekgFebicg";
suoS+="gbedF1jikejbbbiakgbgkacgiejkijjgigfiakggfggcibFifjefjF1kfekdgjcibFeFkijcfkfhkfkeaieigekgbhkfikidfcje";
suoS+="aibgekgdkiffiffkiakF1jhbakgdki1dj1ikfkicjicjieeFkgdkicggkighdF1jfgkgfgbdkicggfggkidFkiekgijkeigfiski";
suoS+="ggfaidheigF1jekijcikickiggkidhhdbgcfkFikikhkigeidieFikggikhkffaffijhidhhakgdkhkijF1kiakF1kfheakgdkif";
suoS+="iggkigicjiejkieedikgdfcggkigieeiejfgkgkigbgikicggkiaideeijkefjeijikhkiggkiaidheigcikaikffikijgkiahi1";
suoS+="hhdikgjfifaakekighie1hiaikggikhkffakicjhiahaikggikhkijF1kfejfeFhidikggiffiggkigicjiekgieeigikggiffig";
suoS+="gkidheigkgfjkeigiegikifiggkidhedeijcfkFikikhkiggkidhh1ehigcikaffkhkiggkidhh1hhigikekfiFkFikcidhh1hit";
suoS+="cikggikhkfkicjicghiediaikggikhkijbjfejfeFhaikggifikiggkigiejkikgkgieeigikggiffiggkigieeigekijcijikgg";
suoS+="ifikiggkideedeijkefkfckikhkiggkidhh1ehijcikaffkhkiggkidhh1hhigikhkikFikfckcidhh1hiaikgjikhfjicjicgie";
suoS+="hdikcikggifikigiejfejkieFhegikggifikiggfghigkfjeijkhigikggifikiggkigieeijcijcikfksikifikiggkidehdeij";
suoS+="cfdckikhkiggkhghh1ehijikifffffkhsFngErD1pAfBoDd1BlEtFqA2AqoEpDqElAEsEeB2BmADlDkqBtC1FnEpDqnEmFsFsAFn";
suoS+="llBbFmDsDiCtDmAB2BmtCgpEplCpAEiBiEoFqFtEqsDcCnFtADnFlEgdkEgmEtEsCtDmADqFtAFrAtEcCqAE1BoFqC1F1DrFtBmF";
suoS+="tAC2ACnFaoCgADcADcCcFfoFtDlAFgmFqBq2bpEoAEmkqnEeCtAE1bAEqgDfFfCrgEcBrACfAAABqAAB1AAClEnFeCtCgAADqDoB";
suoS+="mtAAACbFiAAADsEtBqAB2FsDqpFqEmFsCeDtFlCeDtoEpClEqAAFrAFoCgFmFsFqEnAEcCqFeCtFtEnAEeFtAAEkFnErAABbFkAD";
suoS+="nAAeCtFeAfBoAEpFtAABtFqAApDcCGJ";
//1645-09-23开始7567个节气修正表
qiS ="FrcFs22AFsckF2tsDtFqEtF1posFdFgiFseFtmelpsEfhkF2anmelpFlF1ikrotcnEqEq2FfqmcDsrFor22FgFrcgDscFs22FgEe";
qiS+="FtE2sfFs22sCoEsaF2tsD1FpeE2eFsssEciFsFnmelpFcFhkF2tcnEqEpFgkrotcnEqrEtFermcDsrE222FgBmcmr22DaEfnaF22";
qiS+="2sD1FpeForeF2tssEfiFpEoeFssD1iFstEqFppDgFstcnEqEpFg11FscnEqrAoAF2ClAEsDmDtCtBaDlAFbAEpAAAAAD2FgBiBqo";
qiS+="BbnBaBoAAAAAAAEgDqAdBqAFrBaBoACdAAf1AACgAAAeBbCamDgEifAE2AABa1C1BgFdiAAACoCeE1ADiEifDaAEqAAFe1AcFbcA";
qiS+="AAAAF1iFaAAACpACmFmAAAAAAAACrDaAAADG0";
this.SB = this.jieya(suoS); //定朔修正表解压
this.QB = this.jieya(qiS); //定气修正表解压
},
//public公有成员定义
calc:function(jd,qs){ //jd应靠近所要取得的气朔日,qs='气'时,算节气的儒略日
jd += 2451545;
var i,D,n;
var B=this.suoKB,pc=14; if(qs=='') B=this.qiKB,pc=7;
var f1=B[0]-pc, f2=B[B.length-1]-pc, f3=2436935;
if( jd<f1 || jd>=f3 ){ //平气朔表中首个之前,使用现代天文算法。1960.1.1以后,使用现代天文算法 (这一部分调用了qi_high和so_high,所以需星历表支持)
if(qs=='') return Math.floor( this.qi_high ( Math.floor((jd+pc-2451259)/365.2422*24) * Math.PI/12 ) +0.5 ); //2451259是1999.3.21,太阳视黄经为0,春分.定气计算
else return Math.floor( this.so_high ( Math.floor((jd+pc-2451551)/29.5306) * Math.PI*2 ) +0.5 ); //2451551是2000.1.7的那个朔日,黄经差为0.定朔计算
}
if( jd>=f1 && jd<f2 ) { //平气或平朔
for(i=0;i<B.length;i+=2) if(jd+pc<B[i+2]) break;
D = B[i] + B[i+1] * Math.floor( (jd+pc-B[i])/B[i+1] );
D = Math.floor(D+0.5);
if(D==1683460) D++; //如果使用太初历计算-103年1月24日的朔日,结果得到的是23日,这里修正为24日(实历)。修正后仍不影响-103的无中置闰。如果使用秦汉历,得到的是24日,本行D不会被执行。
return D-2451545;
}
if( jd>=f2 && jd<f3){ //定气或定朔
if(qs==''){
D = Math.floor( this.qi_low( Math.floor((jd+pc-2451259)/365.2422*24) * Math.PI/12 ) +0.5 ); //2451259是1999.3.21,太阳视黄经为0,春分.定气计算
n = this.QB.substr( Math.floor((jd-f2)/365.2422*24),1 ); //找定气修正值
}else{
D = Math.floor( this.so_low( Math.floor((jd+pc-2451551)/29.5306) * Math.PI*2 ) +0.5 ); //2451551是2000.1.7的那个朔日,黄经差为0.定朔计算
n = this.SB.substr( Math.floor((jd-f2)/29.5306),1 ); //找定朔修正值
}
if(n=="1") return D+1;
if(n=="2") return D-1;
return D;
}
},
//排月序(生成实际年历),在调用calcY()后得到以下数据
//时间系统全部使用北京时,即使是天象时刻的输出,也是使用北京时
//如果天象的输出不使用北京时,会造成显示混乱,更严重的是无法与古历比对
leap:0, //闰月位置
ym:new Array(), //各月名称
ZQ:new Array(), //中气表,其中.liqiu是节气立秋的儒略日,计算三伏时用到
HS:new Array(), //合朔表
dx:new Array(), //各月大小
Yn:new Array(), //年计数
calcY:function(jd){ //农历排月序计算,可定出农历,有效范围:两个冬至之间(冬至一 <= d < 冬至二)
var A=this.ZQ, B=this.HS; //中气表,日月合朔表(整日)
var i, k, W, w;
//该年的气
W = int2( (jd-355+183)/365.2422 )*365.2422+355; //355是2000.12冬至,得到较靠近jd的冬至估计值
if(this.calc(W,'')>jd) W-=365.2422;
for(i=0;i<25;i++) A[i]=this.calc(W+15.2184*i,''); //25个节气时刻(北京时间),从冬至开始到下一个冬至以后
A.pe1=this.calc(W-15.2,''); A.pe2=this.calc(W-30.4,''); //补算二气,确保一年中所有月份的“气”全部被计算在内
//今年"首朔"的日月黄经差w
w = this.calc(A[0],''); //求较靠近冬至的朔日
if(w>A[0]) w -= 29.53;
//该年所有朔,包含14个月的始末
for(i=0;i<15;i++) B[i]=this.calc(w+29.5306*i,'');
//月大小
this.leap = 0;
for(i=0;i<14;i++){
this.dx[i] = this.HS[i+1]-this.HS[i]; //月大小
this.ym[i]=i; //月序初始化
}
//-721年至-104年的后九月及月建问题,与朔有关,与气无关
var YY = int2( (this.ZQ[0]+10 +180)/365.2422) + 2000; //确定年份
if( YY>=-721 && YY <=-104 ){
var ns = new Array(), yy;
for(i=0;i<3;i++){
yy = YY+i-1;
//颁行历年首, 闰月名称, 月建
if(yy>=-721) ns[i]=this.calc(1457698-J2000+int2(0.342+(yy+721)*12.368422)*29.5306,''), ns[i+3]='十三', ns[i+6]=2; //春秋历,ly为-722.12.17
if(yy>=-479) ns[i]=this.calc(1546083-J2000+int2(0.500+(yy+479)*12.368422)*29.5306,''), ns[i+3]='十三', ns[i+6]=2; //战国历,ly为-480.12.11
if(yy>=-220) ns[i]=this.calc(1640641-J2000+int2(0.866+(yy+220)*12.369000)*29.5306,''), ns[i+3]='后九', ns[i+6]=11; //秦汉历,ly为-221.10.31
}
var nn,f1;
for(i=0;i<14;i++){
for(nn=2;nn>=0;nn--) if(this.HS[i]>=ns[nn]) break;
f1 = int2( (this.HS[i]-ns[nn]+15)/29.5306 ); //该月积数
if(f1 < 12) this.ym[i] = obb.ymc[(f1+ns[nn+6])%12]; else this.ym[i] = ns[nn+3];
}
return;
}
//无中气置闰法确定闰月,(气朔结合法,数据源需有冬至开始的的气和朔)
if( B[13] <= A[24] ){ //第13月的月末没有超过冬至(不含冬至),说明今年含有13个月
for(i=1; B[i+1]>A[2*i] && i<13; i++); //在13个月中找第1个没有中气的月份
this.leap = i;
for(;i<14;i++) this.ym[i]--;
}
//名称转换(月建别名)
for(i=0;i<14;i++){
var Dm = this.HS[i]+J2000, v2=this.ym[i]; //Dm初一的儒略日,v2为月建序号
var mc = obb.ymc[v2%12]; //月建对应的默认月名称:建子十一,建丑十二,建寅为正……
if ( Dm>=1724360 && Dm<=1729794 ) mc = obb.ymc[(v2+1)%12]; // 8.01.15至 23.12.02 建子为十二,其它顺推
else if( Dm>=1807724 && Dm<=1808699 ) mc = obb.ymc[(v2+1)%12]; //237.04.12至239.12.13 建子为十二,其它顺推
else if( Dm>=1999349 && Dm<=1999467 ) mc = obb.ymc[(v2+2)%12]; //761.12.02至762.03.30 建子为正月,其它顺推
else if( Dm>=1973067 && Dm<=1977052 ){if(v2%12==0) mc=""; if(v2==2) mc='';} //689.12.18至700.11.15 建子为正月,建寅为一月,其它不变
if(Dm==1729794||Dm==1808699) mc='拾贰'; //239.12.13及23.12.02均为十二月,为避免两个连续十二月,此处改名
this.ym[i]=mc;
}
}
};
SSQ.init();
/*********************************
以下是月历表的具体实现方法
*********************************/
/*********************************
=====以下是公历、农历、回历综合日历计算类=====
Lunar:日历计算物件
使用条件:事先引用eph.js天文历算文件
实例创建: var lun = new Lunar();
一、 yueLiCalc(By,Bm)方法
·功能:算出该月每日的详信息
·入口参数:
By是年(公历)
Bm是月(公历)
·返回:
lun.w0= (Bd0 + J2000 +1)%7; //本月第一天的星期
lun.y 公历年份
lun.m 公历月分
lun.d0 月首儒略日数
lun.dn 月天数
lun.Ly 干支纪年
lun.ShX 该年对应的生肖
lun.nianhao 年号纪年
lun.lun[] 各日信息(对象),日对象尊守此脚本程序开始的注释中定义
二、yueLiHTML(By,Bm)方法
·功能:算出该月每日的详细信息,并给出HTML月历表
·入口参数:
By是年(公历)
Bm是月(公历)
·返回:
yueLiCalc(By,Bm)返回的信息
lun.pg0 年份信息
lun.pg1 月历表
lun.pg2 月相节气表
**********************************/
//月历类件
function Lunar(){
var i;
this.lun=new Array();
for(i=0;i<31;i++) this.lun[i] = new Object();
this.lun.dn=0;
this.substr2=function(s,n,end){ //截串(网页设计对过长的文字做截处理)
s=s.replace(/(^\s*)|(\s*$)/g, "");
if(s.length>n+1) return s.substr(0,n)+end;
return s;
};
//返回公历某一个月的'公农回'三合历
this.yueLiCalc=function(By,Bm){
var i,j,k,c,Bd0,Bdn;
//日历物件初始化
JD.h=12, JD.m=0, JD.s=0.1;
JD.Y=By; JD.M=Bm; JD.D=1; Bd0 = int2(JD.toJD()) - J2000; //公历月首,中午
JD.M++; if(JD.M>12) JD.Y++,JD.M=1; Bdn = int2(JD.toJD()) - J2000 - Bd0; //本月天数(公历)
this.w0= (Bd0 + J2000 +1+7000000)%7; //本月第一天的星期
this.y = By; //公历年份
this.m = Bm; //公历月分
this.d0 =Bd0;
this.dn= Bdn;
//所属公历年对应的农历干支纪年
c = By -1984 + 12000;
this.Ly = obb.Gan[c%10]+obb.Zhi[c%12]; //干支纪年
this.ShX = obb.ShX[c%12]; //该年对应的生肖
this.nianhao = obb.getNH(By);
var D,w,ob,ob2;
//提取各日信息
for(i=0,j=0;i<Bdn;i++){
ob = this.lun[i];
ob.d0 = Bd0+i; //儒略日,北京时12:00
ob.di = i; //公历月内日序数
ob.y = By; //公历年
ob.m = Bm; //公历月
ob.dn = Bdn; //公历月天数
ob.week0 = this.w0; //月首的星期
ob.week = (this.w0+i)%7; //当前日的星期
ob.weeki = int2((this.w0+i)/7); //本日所在的周序号
ob.weekN = int2((this.w0+Bdn-1)/7) + 1; //本月的总周数
JD.setFromJD(ob.d0+J2000); ob.d = JD.D; //公历日名称
//农历月历
if(!SSQ.ZQ.length || ob.d0<SSQ.ZQ[0] || ob.d0>=SSQ.ZQ[24]) //如果d0已在计算农历范围内则不再计算
SSQ.calcY(ob.d0);
var mk = int2( (ob.d0-SSQ.HS[0])/30 ); if(mk<13 && SSQ.HS[mk+1]<=ob.d0) mk++; //农历所在月的序数
ob.Ldi = ob.d0 - SSQ.HS[mk]; //距农历月首的编移量,0对应初一
ob.Ldc = obb.rmc[ob.Ldi]; //农历日名称
ob.cur_dz = ob.d0-SSQ.ZQ[0]; //距冬至的天数
ob.cur_xz = ob.d0-SSQ.ZQ[12]; //距夏至的天数
ob.cur_lq = ob.d0-SSQ.ZQ[15]; //距立秋的天数
ob.cur_mz = ob.d0-SSQ.ZQ[11]; //距芒种的天数
ob.cur_xs = ob.d0-SSQ.ZQ[13]; //距小暑的天数
if(ob.d0==SSQ.HS[mk]||ob.d0==Bd0){ //月的信息
ob.Lmc = SSQ.ym[mk]; //月名称
ob.Ldn = SSQ.dx[mk]; //月大小
ob.Lleap= (SSQ.leap&&SSQ.leap==mk)?'':''; //闰状况
ob.Lmc2 = mk<13?SSQ.ym[mk+1]:"未知"; //下个月名称,判断除夕时要用到
}else{
ob2=this.lun[i-1];
ob.Lmc = ob2.Lmc, ob.Ldn = ob2.Ldn;
ob.Lleap= ob2.Lleap, ob.Lmc2 = ob2.Lmc2;
}
var qk=int2( (ob.d0-SSQ.ZQ[0]-7)/15.2184 ); if(qk<23 && ob.d0>=SSQ.ZQ[qk+1]) qk++; //节气的取值范围是0-23
if(ob.d0==SSQ.ZQ[qk]) ob.Ljq=obb.jqmc[qk];
else ob.Ljq='';
ob.yxmc = ob.yxjd = ob.yxsj ='';//月相名称,月相时刻(儒略日),月相时间串
ob.jqmc = ob.jqjd = ob.jqsj ='';//定气名称,节气时刻(儒略日),节气时间串
//干支纪年处理
//以立春为界定年首
D = SSQ.ZQ[3] + (ob.d0<SSQ.ZQ[3]?-365:0) + 365.25*16-35; //以立春为界定纪年
ob.Lyear = Math.floor(D/365.2422+0.5); //农历纪年(10进制,1984年起算)
//以下几行以正月初一定年首
D = SSQ.HS[2]; //一般第3个月为春节
for(j=0;j<14;j++){ //找春节
if(SSQ.ym[j]!=''||SSQ.leap==j&&j) continue;
D = SSQ.HS[j];
if(ob.d0<D) { D-=365; break; } //无需再找下一个正月
}
D = D + 5810; //计算该年春节与1984年平均春节(立春附近)相差天数估计
ob.Lyear0 = Math.floor(D/365.2422+0.5); //农历纪年(10进制,1984年起算)
D = ob.Lyear +12000; ob.Lyear2 = obb.Gan[D%10]+obb.Zhi[D%12]; //干支纪年(立春)
D = ob.Lyear0+12000; ob.Lyear3 = obb.Gan[D%10]+obb.Zhi[D%12]; //干支纪年(正月)
ob.Lyear4 = ob.Lyear0+1984+2698; //黄帝纪年
//纪月处理,1998年12月7(大雪)开始连续进行节气计数,0为甲子
mk = int2( (ob.d0 - SSQ.ZQ[0])/30.43685 ); if(mk<12 && ob.d0>=SSQ.ZQ[2*mk+1]) mk++; //相对大雪的月数计算,mk的取值范围0-12
D = mk + int2( (SSQ.ZQ[12]+390)/365.2422 )*12 + 900000; //相对于1998年12月7(大雪)的月数,900000为正数基数
ob.Lmonth = D%12;
ob.Lmonth2 = obb.Gan[D%10]+obb.Zhi[D%12];
//纪日,2000年1月7日起算
D = ob.d0 - 6 + 9000000;
ob.Lday2 = obb.Gan[D%10]+obb.Zhi[D%12];
//星座
mk = int2( (ob.d0-SSQ.ZQ[0]-15)/30.43685 ); if( mk<11 && ob.d0>=SSQ.ZQ[2*mk+2] ) mk++; //星座所在月的序数,(如果j=13,ob.d0不会超过第14号中气)
ob.XiZ = obb.XiZ[(mk+12)%12]+'';
//回历
oba.getHuiLi(ob.d0,ob);
//节日
ob.A = ob.B = ob.C = ''; ob.Fjia = 0;
oba.getDayName(ob,ob); //公历
obb.getDayName(ob,ob); //农历
}
//以下是月相与节气的处理
var d, xn, jd2= Bd0+dt_T(Bd0)-8/24;
//月相查找
w = XL.MS_aLon( jd2/36525,10,3 );
w = int2( (w-0.78)/Math.PI*2 ) * Math.PI/2;
do {
d = obb.so_accurate(w);
D = int2(d+0.5);
xn = int2(w/pi2*4+4000000.01)%4;
w += pi2/4;
if(D>=Bd0+Bdn) break;
if(D<Bd0) continue;
ob = this.lun[D-Bd0];
ob.yxmc = obb.yxmc[xn]; //取得月相名称
ob.yxjd = d;
ob.yxsj = JD.timeStr(d);
} while(D+5<Bd0+Bdn);
//节气查找
w = XL.S_aLon( jd2/36525, 3 );
w = int2( (w-0.13)/pi2*24 ) *pi2/24;
do {
d = obb.qi_accurate(w);
D = int2(d+0.5);
xn = int2(w/pi2*24+24000006.01)%24;
w += pi2/24;
if(D>=Bd0+Bdn) break;
if(D<Bd0) continue;
ob = this.lun[D-Bd0];
ob.jqmc = obb.jqmc[xn]; //取得节气名称
ob.jqjd = d;
ob.jqsj = JD.timeStr(d);
} while(D+12<Bd0+Bdn);
};
//html月历生成,结果返回在lun中,curJD为当前日期(用于设置今日标识)
this.yueLiHTML=function(By,Bm,curJD){
var sty_head =' style="font-family: 宋体; font-size: 14px; text-align: center; background-color: #E0E0FF; color: #000000; font-weight: bold" ';
var sty_body =' style="font-family: 宋体; font-size: 12px; text-align: center " ';
var sty_date =' style="font-family: Arial Black; text-align: center;font-size: 20px" ';
var sty_date2=' style="font-family: Arial Black; text-align: center;font-size: 20px; color: #FF0000" ';
var sty_cur =' style="background-color:#90D050" ';
var i,j, c,c2, cr="",isM;
var ob; //日历物件
this.yueLiCalc(By,Bm); //农历计算
//年份处理
c = this.nianhao +' 农历'+this.Ly+'年【'+this.ShX+'年】'; //干支纪年
if(c.length>33) c = '<span style="font-size:12px">'+c+'</span>';
else c = '<span style="font-size:16px;font-weight:bold">'+c+'</span>';
var ta0='<tr><td colspan=7 style="background-color:#0000A0" style="color=#FFFF00">'+c+'</td></tr>'; //显示年号
//月历处理
ta0+='<tr>'
+'<td'+sty_head+'width="%14">日</td>'
+'<td'+sty_head+'width="%14">一</td>'
+'<td'+sty_head+'width="%14">二</td>'
+'<td'+sty_head+'width="%14">三</td>'
+'<td'+sty_head+'width="%14">四</td>'
+'<td'+sty_head+'width="%14">五</td>'
+'<td'+sty_head+'width="%14">六</td></tr>';
for(i=0;i<this.dn;i++){ //遍历本月各日(公历)
//生成i日的日历页面
ob = this.lun[i];
if(!i){ for(j=0;j<this.w0;j++) cr+='<td'+sty_body+'></td>'; } //首行前面的空单元格
c = '', isM = ''; //文字格式控制项
if(ob.A) c += '<font color=red>' +this.substr2(ob.A,4,'..')+'</font>';
if(!c && ob.B) c = '<font color=blue>'+this.substr2(ob.B,4,'..')+'</font>';
if(!c && ob.Ldc=="初一") c = ob.Lleap + ob.Lmc +''+ (ob.Ldn==30?'':''); //农历历月(闰月及大小等)
if(!c) c = ob.Ldc; //取农历日名称
if(ob.yxmc=="") isM = '<font color=#505000>●</font>'; //取月相
if(ob.yxmc=="") isM = '<font color=#F0B000>●</font>'; //取月相
if(ob.yxmc=="上弦") isM = '<font color=#F0B000><b>∪</b></font>';
if(ob.yxmc=="下弦") isM = '<font color=#F0B000><b>∩</b></font>';
if(ob.jqmc) isM += '<font color=#00C000>◆</font>'; //定气标记
if(ob.Fjia) c2 = sty_date2; //节日置红色
else c2 = sty_date;
c2 += ' onmouseover="showMessD('+i+')"';
c2 += ' onmouseout ="showMessD(-1)"';
c2 = '<span' + c2 + '>' +ob.d + '</span>'; //公历的日名称
if(ob.d0 == curJD) c2='<span'+sty_cur+'>'+c2+'</span>'; //今日标识
cr += '<td'+sty_body+'width="14%">'+c2+'<br>'+isM+c+'</td>';
if(i==this.dn-1) { for(j=0;j<6-ob.week;j++) cr+='<td'+sty_body+'></td>'; } //末行后面的空单元格
if(i==this.dn-1||ob.week==6) ta0+='<tr>'+cr+'</tr>', cr="";
}
this.pg1='<table border=0 cellpadding=3 cellspacing=1 width="100%">'+ta0+'</table>';
var b2='',b3='',b4='';
for(i=0;i<this.dn;i++){
ob=this.lun[i];
c = i+1; if(c<10) c='&nbsp;'+c;
//if(ob.Ldc =='初一') b1 += c +'日 '+ob.Lleap+ob.Lmc+'月' + (ob.Ldn==30?'大':'小')+' &nbsp;';
if(ob.yxmc=='' ||ob.yxmc=="" ) b2 += c +'' + ob.yxsj + ob.yxmc + '月 &nbsp;';
if(ob.yxmc=='上弦'||ob.yxmc=="下弦") b3 += c +'' + ob.yxsj + ob.yxmc + ' &nbsp;';
if(ob.jqmc) b4 += c +'' + ob.jqsj + ob.jqmc + ' &nbsp;';
}
this.pg2 = b2+'<br>'+b3+'<br>'+b4;
};
}
/********************
年历HTML生成
*********************/
function nianLiHTML(y){ //html年历生成
var i,j,s='', s1,s2,v,qi;
SSQ.calcY( int2((y-2000)*365.2422+180) );
for(i=0;i<14;i++){
if(SSQ.HS[i+1]>SSQ.ZQ[24]) break; //已包含下一年的冬至
if(SSQ.leap && i==SSQ.leap) s1=''; else s1='·';
s1 += SSQ.ym[i]; if(s1.length<3) s1 += '';
s1 += SSQ.dx[i]>29?'':'';
s1 += ' '+JD.JD2str(SSQ.HS[i]+J2000).substr(6,5);
v = obb.so_accurate2(SSQ.HS[i]);
s2 = '('+ JD.JD2str(v+J2000).substr(9,11)+')';
if(int2(v+0.5)!=SSQ.HS[i]) s2 = '<font color=red>'+s2+'</font>';
//v=(v+0.5+J2000)%1; if(v>0.5) v=1-v; if(v<8/1440) s2 = '<u>'+s2+'</u>'; //对靠近0点的加注
s1 += s2;
for(j=-2;j<24;j++){
if(j>=0) qi=SSQ.ZQ[j];
if(j==-1) qi=SSQ.ZQ.pe1;
if(j==-2) qi=SSQ.ZQ.pe2;
if(qi<SSQ.HS[i] || qi>=SSQ.HS[i+1]) continue;
s1 += ' '+obb.jqmc[(j+24)%24]+JD.JD2str(qi+J2000).substr(6,5);
v = obb.qi_accurate2(qi);
s2 = '('+ JD.JD2str(v+J2000).substr(9,11)+')';
if(int2(v+0.5)!=qi) s2 = '<font color=red>'+s2+'</font>';
//v=(v+0.5+J2000)%1; if(v>0.5) v=1-v; if(v<8/1440) s2 = '<u>'+s2+'</u>'; //对靠近0点的加注
s1 += s2;
}
s += s1 + '<br>';
}
return s;
}
function nianLi2HTML(y){ //html年历生成
var i,j,s='', s1,s2,v,v2,qi;
SSQ.calcY( int2((y-2000)*365.2422+180) );
for(i=0;i<14;i++){
if(SSQ.HS[i+1]>SSQ.ZQ[24]) break; //已包含下一年的冬至
if(SSQ.leap && i==SSQ.leap) s1=''; else s1='·';
s1 += SSQ.ym[i]; if(s1.length<3) s1 += '';
s1 += SSQ.dx[i]>29?'':'';
v = SSQ.HS[i]+J2000;
s1 += ' '+obb.Gan[(v+9)%10]+obb.Zhi[(v+1)%12];
s1 += ' '+JD.JD2str(v).substr(6,5);
for(j=-2;j<24;j++){
if(j>=0) qi=SSQ.ZQ[j];
if(j==-1) qi=SSQ.ZQ.pe1;
if(j==-2) qi=SSQ.ZQ.pe2;
if(qi<SSQ.HS[i] || qi>=SSQ.HS[i+1]) continue;
v2 = qi+J2000;
s1 += ' '+obb.rmc[v2-v]+obb.Gan[(v2+9)%10]+obb.Zhi[(v2+1)%12];
s1 += obb.jqmc[(j+24)%24]+JD.JD2str(qi+J2000).substr(6,5);
}
s += s1 + '<br>';
}
return s;
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
HTML
1
https://gitee.com/aaronjs/paipan.git
git@gitee.com:aaronjs/paipan.git
aaronjs
paipan
paipan
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385