|
|
|
|
@@ -27,13 +27,7 @@
|
|
|
|
|
fromYmdHms:function(y,m,d,hour,minute,second){
|
|
|
|
|
return this._(new Date(y+'/'+m+'/'+d+' '+hour+':'+minute+':'+second),y,m,d);
|
|
|
|
|
},
|
|
|
|
|
getDaysBetween:function(date0, date1){
|
|
|
|
|
var ay = date0.getFullYear();
|
|
|
|
|
var by = date1.getFullYear();
|
|
|
|
|
var am = date0.getMonth() + 1;
|
|
|
|
|
var bm = date1.getMonth() + 1;
|
|
|
|
|
var ad = date0.getDate();
|
|
|
|
|
var bd = date1.getDate();
|
|
|
|
|
getDaysBetweenYmd:function(ay, am, ad, by, bm, bd){
|
|
|
|
|
var n;
|
|
|
|
|
var days;
|
|
|
|
|
var i;
|
|
|
|
|
@@ -55,6 +49,9 @@
|
|
|
|
|
n = days;
|
|
|
|
|
}
|
|
|
|
|
return n;
|
|
|
|
|
},
|
|
|
|
|
getDaysBetween:function(date0, date1){
|
|
|
|
|
return this.getDaysBetweenYmd(date0.getFullYear(), date0.getMonth() + 1, date0.getDate(), date1.getFullYear(), date1.getMonth() + 1, date1.getDate());
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
})();
|
|
|
|
|
@@ -304,7 +301,7 @@
|
|
|
|
|
if(offsetYear<0){
|
|
|
|
|
offsetYear = offsetYear+60;
|
|
|
|
|
}
|
|
|
|
|
var startYear = today.getYear() - offsetYear;
|
|
|
|
|
var startYear = lunar.getYear() - offsetYear;
|
|
|
|
|
var hour = 0;
|
|
|
|
|
var timeZhi = timeGanZhi.substr(1);
|
|
|
|
|
for(var i=0,j=LunarUtil.ZHI.length;i<j;i++){
|
|
|
|
|
@@ -366,7 +363,7 @@
|
|
|
|
|
fromYmdHms:function(y,m,d,hour,minute,second){return _fromYmdHms(y,m,d,hour,minute,second);},
|
|
|
|
|
fromDate:function(date){return _fromDate(date);},
|
|
|
|
|
fromJulianDay:function(julianDay){return _fromJulianDay(julianDay);},
|
|
|
|
|
fromBaZi:function(yearGanZhi,monthGanZhi,dayGanZhi,timeGanZhi){return _fromBaZi(yearGanZhi,monthGanZhi,dayGanZhi,timeGanZhi);}
|
|
|
|
|
fromBaZi:function(yearGanZhi,monthGanZhi,dayGanZhi,timeGanZhi,sect,baseYear){return _fromBaZi(yearGanZhi,monthGanZhi,dayGanZhi,timeGanZhi,sect,baseYear);}
|
|
|
|
|
};
|
|
|
|
|
})();
|
|
|
|
|
var Lunar = (function(){
|
|
|
|
|
@@ -527,22 +524,19 @@
|
|
|
|
|
return o;
|
|
|
|
|
};
|
|
|
|
|
var _fromDate = function(date){
|
|
|
|
|
var c = ExactDate.fromYmd(date.getFullYear(),date.getMonth()+1,date.getDate());
|
|
|
|
|
var currentYear = date.getFullYear();
|
|
|
|
|
var currentMonth = date.getMonth() + 1;
|
|
|
|
|
var currentDay = date.getDate();
|
|
|
|
|
var lunarYear = 0;
|
|
|
|
|
var lunarMonth = 0;
|
|
|
|
|
var lunarDay = 0;
|
|
|
|
|
var y = c.getFullYear();
|
|
|
|
|
var ly = LunarYear.fromYear(y);
|
|
|
|
|
var ly = LunarYear.fromYear(currentYear);
|
|
|
|
|
var lms = ly.getMonths();
|
|
|
|
|
for (var i = 0, j = lms.length; i < j; i++) {
|
|
|
|
|
var m = lms[i];
|
|
|
|
|
// 初一
|
|
|
|
|
var firstDay = Solar.fromJulianDay(m.getFirstJulianDay()).getCalendar();
|
|
|
|
|
firstDay.setHours(0);
|
|
|
|
|
firstDay.setMinutes(0);
|
|
|
|
|
firstDay.setSeconds(0);
|
|
|
|
|
firstDay.setMilliseconds(0);
|
|
|
|
|
var days = ExactDate.getDaysBetween(firstDay, c);
|
|
|
|
|
var firstDay = Solar.fromJulianDay(m.getFirstJulianDay());
|
|
|
|
|
var days = ExactDate.getDaysBetweenYmd(firstDay.getYear(), firstDay.getMonth(), firstDay.getDay(), currentYear, currentMonth, currentDay);
|
|
|
|
|
if (days < m.getDayCount()) {
|
|
|
|
|
lunarYear = m.getYear();
|
|
|
|
|
lunarMonth = m.getMonth();
|
|
|
|
|
@@ -776,9 +770,9 @@
|
|
|
|
|
getTimePositionCaiDesc:function(){
|
|
|
|
|
return LunarUtil.POSITION_DESC[this.getTimePositionCai()];
|
|
|
|
|
},
|
|
|
|
|
getDayPositionTaiSui:function(){
|
|
|
|
|
_getDayPositionTaiSui:function(dayInGanZhi, yearZhiIndex){
|
|
|
|
|
var p = '';
|
|
|
|
|
switch (this.getDayInGanZhi()) {
|
|
|
|
|
switch (dayInGanZhi) {
|
|
|
|
|
case '甲子':
|
|
|
|
|
case '乙丑':
|
|
|
|
|
case '丙寅':
|
|
|
|
|
@@ -820,12 +814,91 @@
|
|
|
|
|
p = '坎';
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
p = LunarYear.fromYear(this.getYear()).getPositionTaiSui();
|
|
|
|
|
p = LunarUtil.POSITION_TAI_SUI_YEAR[yearZhiIndex];
|
|
|
|
|
}
|
|
|
|
|
return p;
|
|
|
|
|
},
|
|
|
|
|
getDayPositionTaiSuiDesc:function(){
|
|
|
|
|
return LunarUtil.POSITION_DESC[this.getDayPositionTaiSui()];
|
|
|
|
|
getDayPositionTaiSui:function(sect){
|
|
|
|
|
var dayInGanZhi;
|
|
|
|
|
var yearZhiIndex;
|
|
|
|
|
switch (sect) {
|
|
|
|
|
case 1:
|
|
|
|
|
dayInGanZhi = this.getDayInGanZhi();
|
|
|
|
|
yearZhiIndex = this._p.yearZhiIndex;
|
|
|
|
|
break;
|
|
|
|
|
case 3:
|
|
|
|
|
dayInGanZhi = this.getDayInGanZhi();
|
|
|
|
|
yearZhiIndex = this._p.yearZhiIndexExact;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
dayInGanZhi = this.getDayInGanZhiExact2();
|
|
|
|
|
yearZhiIndex = this._p.yearZhiIndexByLiChun;
|
|
|
|
|
}
|
|
|
|
|
return this._getDayPositionTaiSui(dayInGanZhi, yearZhiIndex);
|
|
|
|
|
},
|
|
|
|
|
getDayPositionTaiSuiDesc:function(sect){
|
|
|
|
|
return LunarUtil.POSITION_DESC[this.getDayPositionTaiSui(sect)];
|
|
|
|
|
},
|
|
|
|
|
_getMonthPositionTaiSui:function(monthZhiIndex, monthGanIndex){
|
|
|
|
|
var p = '';
|
|
|
|
|
var m = monthZhiIndex - LunarUtil.BASE_MONTH_ZHI_INDEX;
|
|
|
|
|
if (m < 0) {
|
|
|
|
|
m += 12;
|
|
|
|
|
}
|
|
|
|
|
switch(m) {
|
|
|
|
|
case 0:
|
|
|
|
|
case 4:
|
|
|
|
|
case 8:
|
|
|
|
|
p = '艮';
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
case 6:
|
|
|
|
|
case 10:
|
|
|
|
|
p = '坤';
|
|
|
|
|
break;
|
|
|
|
|
case 3:
|
|
|
|
|
case 7:
|
|
|
|
|
case 11:
|
|
|
|
|
p = '巽';
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
p = LunarUtil.POSITION_GAN[monthGanIndex];
|
|
|
|
|
}
|
|
|
|
|
return p;
|
|
|
|
|
},
|
|
|
|
|
getMonthPositionTaiSui:function(sect){
|
|
|
|
|
var monthZhiIndex;
|
|
|
|
|
var monthGanIndex;
|
|
|
|
|
switch (sect) {
|
|
|
|
|
case 3:
|
|
|
|
|
monthZhiIndex = this._p.monthZhiIndexExact;
|
|
|
|
|
monthGanIndex = this._p.monthGanIndexExact;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
monthZhiIndex = this._p.monthZhiIndex;
|
|
|
|
|
monthGanIndex = this._p.monthGanIndex;
|
|
|
|
|
}
|
|
|
|
|
return this._getMonthPositionTaiSui(monthZhiIndex, monthGanIndex);
|
|
|
|
|
},
|
|
|
|
|
getMonthPositionTaiSuiDesc:function(sect){
|
|
|
|
|
return LunarUtil.POSITION_DESC[this.getMonthPositionTaiSui(sect)];
|
|
|
|
|
},
|
|
|
|
|
getYearPositionTaiSui:function(sect){
|
|
|
|
|
var yearZhiIndex;
|
|
|
|
|
switch (sect) {
|
|
|
|
|
case 1:
|
|
|
|
|
yearZhiIndex = this._p.yearZhiIndex;
|
|
|
|
|
break;
|
|
|
|
|
case 3:
|
|
|
|
|
yearZhiIndex = this._p.yearZhiIndexExact;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
yearZhiIndex = this._p.yearZhiIndexByLiChun;
|
|
|
|
|
}
|
|
|
|
|
return LunarUtil.POSITION_TAI_SUI_YEAR[yearZhiIndex];
|
|
|
|
|
},
|
|
|
|
|
getYearPositionTaiSuiDesc:function(sect){
|
|
|
|
|
return LunarUtil.POSITION_DESC[this.getYearPositionTaiSui(sect)];
|
|
|
|
|
},
|
|
|
|
|
getChong:function(){
|
|
|
|
|
return this.getDayChong();
|
|
|
|
|
@@ -910,59 +983,51 @@
|
|
|
|
|
},
|
|
|
|
|
_convertJieQi:function(name){
|
|
|
|
|
var jq = name;
|
|
|
|
|
if('DONG_ZHI'===jq){
|
|
|
|
|
if('DONG_ZHI' === jq){
|
|
|
|
|
jq = '冬至';
|
|
|
|
|
}else if('DA_HAN'===jq){
|
|
|
|
|
}else if('DA_HAN' === jq){
|
|
|
|
|
jq = '大寒';
|
|
|
|
|
}else if('XIAO_HAN'===jq){
|
|
|
|
|
}else if('XIAO_HAN' === jq){
|
|
|
|
|
jq = '小寒';
|
|
|
|
|
}else if('LI_CHUN'===jq){
|
|
|
|
|
}else if('LI_CHUN' === jq){
|
|
|
|
|
jq = '立春';
|
|
|
|
|
}else if('DA_XUE'===jq){
|
|
|
|
|
}else if('DA_XUE' === jq){
|
|
|
|
|
jq = '大雪';
|
|
|
|
|
}else if('YU_SHUI'===jq){
|
|
|
|
|
}else if('YU_SHUI' === jq){
|
|
|
|
|
jq = '雨水';
|
|
|
|
|
}else if('JING_ZHE'===jq){
|
|
|
|
|
}else if('JING_ZHE' === jq){
|
|
|
|
|
jq = '惊蛰';
|
|
|
|
|
}
|
|
|
|
|
return jq;
|
|
|
|
|
},
|
|
|
|
|
getJie:function(){
|
|
|
|
|
var d;
|
|
|
|
|
var jie='';
|
|
|
|
|
for(var i=0,j=Lunar.JIE_QI_IN_USE.length;i<j;i+=2){
|
|
|
|
|
for(var i=0, j=Lunar.JIE_QI_IN_USE.length; i<j; i+=2){
|
|
|
|
|
var key = Lunar.JIE_QI_IN_USE[i];
|
|
|
|
|
d = this._p.jieQi[key];
|
|
|
|
|
if(d.getYear()===this._p.solar.getYear()&&d.getMonth()===this._p.solar.getMonth()&&d.getDay()===this._p.solar.getDay()){
|
|
|
|
|
jie=key;
|
|
|
|
|
break;
|
|
|
|
|
var d = this._p.jieQi[key];
|
|
|
|
|
if(d.getYear() === this._p.solar.getYear() && d.getMonth() === this._p.solar.getMonth() && d.getDay() === this._p.solar.getDay()){
|
|
|
|
|
return this._convertJieQi(key);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return this._convertJieQi(jie);
|
|
|
|
|
return '';
|
|
|
|
|
},
|
|
|
|
|
getQi:function(){
|
|
|
|
|
var d;
|
|
|
|
|
var qi='';
|
|
|
|
|
for(var i=1,j=Lunar.JIE_QI_IN_USE.length;i<j;i+=2){
|
|
|
|
|
for(var i=1, j=Lunar.JIE_QI_IN_USE.length; i<j; i+=2){
|
|
|
|
|
var key = Lunar.JIE_QI_IN_USE[i];
|
|
|
|
|
d = this._p.jieQi[key];
|
|
|
|
|
if(d.getYear()===this._p.solar.getYear()&&d.getMonth()===this._p.solar.getMonth()&&d.getDay()===this._p.solar.getDay()){
|
|
|
|
|
qi=key;
|
|
|
|
|
break;
|
|
|
|
|
var d = this._p.jieQi[key];
|
|
|
|
|
if(d.getYear() === this._p.solar.getYear() && d.getMonth() === this._p.solar.getMonth() && d.getDay() === this._p.solar.getDay()){
|
|
|
|
|
return this._convertJieQi(key);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return this._convertJieQi(qi);
|
|
|
|
|
return '';
|
|
|
|
|
},
|
|
|
|
|
getJieQi:function(){
|
|
|
|
|
var name = '';
|
|
|
|
|
for(var key in this._p.jieQi){
|
|
|
|
|
var d = this._p.jieQi[key];
|
|
|
|
|
if(d.getYear()==this._p.solar.getYear()&&d.getMonth()==this._p.solar.getMonth()&&d.getDay()==this._p.solar.getDay()){
|
|
|
|
|
name = key;
|
|
|
|
|
break;
|
|
|
|
|
if(d.getYear() === this._p.solar.getYear() && d.getMonth() === this._p.solar.getMonth() && d.getDay() === this._p.solar.getDay()){
|
|
|
|
|
return this._convertJieQi(key);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return this._convertJieQi(name);
|
|
|
|
|
return '';
|
|
|
|
|
},
|
|
|
|
|
getWeek:function(){
|
|
|
|
|
return this._p.weekIndex;
|
|
|
|
|
@@ -1130,26 +1195,59 @@
|
|
|
|
|
getYueXiang:function(){
|
|
|
|
|
return LunarUtil.YUE_XIANG[this._p.day];
|
|
|
|
|
},
|
|
|
|
|
getYearNineStar:function(){
|
|
|
|
|
return LunarYear.fromYear(this._p.year).getNineStar();
|
|
|
|
|
_getYearNineStar:function(yearInGanZhi){
|
|
|
|
|
var index = LunarUtil.getJiaZiIndex(yearInGanZhi) + 1;
|
|
|
|
|
var yearOffset = 0;
|
|
|
|
|
if (index != LunarUtil.getJiaZiIndex(this.getYearInGanZhi()) + 1) {
|
|
|
|
|
yearOffset = -1;
|
|
|
|
|
}
|
|
|
|
|
var yuan = Math.floor((this._p.year + yearOffset + 2696) / 60) % 3;
|
|
|
|
|
var offset = (62 + yuan * 3 - index) % 9;
|
|
|
|
|
if(0 === offset){
|
|
|
|
|
offset = 9;
|
|
|
|
|
}
|
|
|
|
|
return NineStar.fromIndex(offset - 1);
|
|
|
|
|
},
|
|
|
|
|
getMonthNineStar:function(){
|
|
|
|
|
var n = 12;
|
|
|
|
|
var yearZhi = this.getYearZhi();
|
|
|
|
|
if ('子午卯酉'.indexOf(yearZhi)>-1) {
|
|
|
|
|
n = 18;
|
|
|
|
|
} else if ('辰戌丑未'.indexOf(yearZhi)>-1) {
|
|
|
|
|
n = 15;
|
|
|
|
|
getYearNineStar:function(sect){
|
|
|
|
|
var yearInGanZhi;
|
|
|
|
|
switch (sect) {
|
|
|
|
|
case 1:
|
|
|
|
|
yearInGanZhi = this.getYearInGanZhi();
|
|
|
|
|
break;
|
|
|
|
|
case 3:
|
|
|
|
|
yearInGanZhi = this.getYearInGanZhiExact();
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
yearInGanZhi = this.getYearInGanZhiByLiChun();
|
|
|
|
|
}
|
|
|
|
|
var m = this._p.month;
|
|
|
|
|
if(m<0){
|
|
|
|
|
m = -m;
|
|
|
|
|
return this._getYearNineStar(yearInGanZhi);
|
|
|
|
|
},
|
|
|
|
|
_getMonthNineStar:function(yearZhiIndex, monthZhiIndex){
|
|
|
|
|
var index = yearZhiIndex % 3;
|
|
|
|
|
var n = 27 - (index * 3);
|
|
|
|
|
if (monthZhiIndex < LunarUtil.BASE_MONTH_ZHI_INDEX) {
|
|
|
|
|
n -= 3;
|
|
|
|
|
}
|
|
|
|
|
var offset = (n-m)%9;
|
|
|
|
|
if(0===offset){
|
|
|
|
|
offset=9;
|
|
|
|
|
var offset = (n - monthZhiIndex) % 9;
|
|
|
|
|
return NineStar.fromIndex(offset);
|
|
|
|
|
},
|
|
|
|
|
getMonthNineStar:function(sect){
|
|
|
|
|
var yearZhiIndex;
|
|
|
|
|
var monthZhiIndex;
|
|
|
|
|
switch (sect) {
|
|
|
|
|
case 1:
|
|
|
|
|
yearZhiIndex = this._p.yearZhiIndex;
|
|
|
|
|
monthZhiIndex = this._p.monthZhiIndex;
|
|
|
|
|
break;
|
|
|
|
|
case 3:
|
|
|
|
|
yearZhiIndex = this._p.yearZhiIndexExact;
|
|
|
|
|
monthZhiIndex = this._p.monthZhiIndexExact;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
yearZhiIndex = this._p.yearZhiIndexByLiChun;
|
|
|
|
|
monthZhiIndex = this._p.monthZhiIndex;
|
|
|
|
|
}
|
|
|
|
|
return NineStar.fromIndex(offset-1);
|
|
|
|
|
return this._getMonthNineStar(yearZhiIndex, monthZhiIndex);
|
|
|
|
|
},
|
|
|
|
|
getDayNineStar:function(){
|
|
|
|
|
var solarYmd = this._p.solar.toYmd();
|
|
|
|
|
@@ -1159,9 +1257,9 @@
|
|
|
|
|
var dongZhiIndex = LunarUtil.getJiaZiIndex(dongZhi.getLunar().getDayInGanZhi());
|
|
|
|
|
var dongZhiIndex2 = LunarUtil.getJiaZiIndex(dongZhi2.getLunar().getDayInGanZhi());
|
|
|
|
|
var xiaZhiIndex = LunarUtil.getJiaZiIndex(xiaZhi.getLunar().getDayInGanZhi());
|
|
|
|
|
var solarShunBai = null;
|
|
|
|
|
var solarShunBai2 = null;
|
|
|
|
|
var solarNiZi = null;
|
|
|
|
|
var solarShunBai;
|
|
|
|
|
var solarShunBai2;
|
|
|
|
|
var solarNiZi;
|
|
|
|
|
if (dongZhiIndex>29) {
|
|
|
|
|
solarShunBai = dongZhi.next(60 - dongZhiIndex);
|
|
|
|
|
} else {
|
|
|
|
|
@@ -1206,8 +1304,7 @@
|
|
|
|
|
start = asc ? 3 : 5;
|
|
|
|
|
}
|
|
|
|
|
var index = asc ? start + this._p.timeZhiIndex : start + 9 - this._p.timeZhiIndex;
|
|
|
|
|
var offset = index % 9;
|
|
|
|
|
return NineStar.fromIndex(offset);
|
|
|
|
|
return NineStar.fromIndex(index % 9);
|
|
|
|
|
},
|
|
|
|
|
getSolar:function(){
|
|
|
|
|
return this._p.solar;
|
|
|
|
|
@@ -1324,16 +1421,33 @@
|
|
|
|
|
return this._buildJieQi(name, near);
|
|
|
|
|
},
|
|
|
|
|
getCurrentJieQi:function(){
|
|
|
|
|
var name = this.getJieQi();
|
|
|
|
|
return name.length>0 ? this._buildJieQi(name,this.solar) : null;
|
|
|
|
|
for(var key in this._p.jieQi){
|
|
|
|
|
var d = this._p.jieQi[key];
|
|
|
|
|
if(d.getYear() === this._p.solar.getYear() && d.getMonth() === this._p.solar.getMonth() && d.getDay() === this._p.solar.getDay()){
|
|
|
|
|
return this._buildJieQi(this._convertJieQi(key), d);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
},
|
|
|
|
|
getCurrentJie:function(){
|
|
|
|
|
var name = this.getJie();
|
|
|
|
|
return name.length>0 ? this._buildJieQi(name,this.solar) : null;
|
|
|
|
|
for(var i=0, j=Lunar.JIE_QI_IN_USE.length; i<j; i+=2){
|
|
|
|
|
var key = Lunar.JIE_QI_IN_USE[i];
|
|
|
|
|
var d = this._p.jieQi[key];
|
|
|
|
|
if(d.getYear() === this._p.solar.getYear() && d.getMonth() === this._p.solar.getMonth() && d.getDay() === this._p.solar.getDay()){
|
|
|
|
|
return this._buildJieQi(this._convertJieQi(key), d);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
},
|
|
|
|
|
getCurrentQi:function(){
|
|
|
|
|
var name = this.getQi();
|
|
|
|
|
return name.length>0 ? this._buildJieQi(name,this.solar) : null;
|
|
|
|
|
for(var i=1, j=Lunar.JIE_QI_IN_USE.length; i<j; i+=2){
|
|
|
|
|
var key = Lunar.JIE_QI_IN_USE[i];
|
|
|
|
|
var d = this._p.jieQi[key];
|
|
|
|
|
if(d.getYear() === this._p.solar.getYear() && d.getMonth() === this._p.solar.getMonth() && d.getDay() === this._p.solar.getDay()){
|
|
|
|
|
return this._buildJieQi(this._convertJieQi(key), d);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
},
|
|
|
|
|
getEightChar:function(){
|
|
|
|
|
if(!this._p.eightChar){
|
|
|
|
|
@@ -1545,11 +1659,14 @@
|
|
|
|
|
getHou:function(){
|
|
|
|
|
var jieQi = this.getPrevJieQi(true);
|
|
|
|
|
var name = jieQi.getName();
|
|
|
|
|
var currentCalendar = ExactDate.fromYmd(this._p.solar.getYear(),this._p.solar.getMonth(),this._p.solar.getDay());
|
|
|
|
|
var startSolar = jieQi.getSolar();
|
|
|
|
|
var startCalendar = ExactDate.fromYmd(startSolar.getYear(),startSolar.getMonth(),startSolar.getDay());
|
|
|
|
|
var days = days = ExactDate.getDaysBetween(startCalendar, currentCalendar);
|
|
|
|
|
return name + ' ' + LunarUtil.HOU[(Math.floor(days/5)) % LunarUtil.HOU.length];
|
|
|
|
|
var days = ExactDate.getDaysBetweenYmd(startSolar.getYear(),startSolar.getMonth(),startSolar.getDay(), this._p.solar.getYear(),this._p.solar.getMonth(),this._p.solar.getDay());
|
|
|
|
|
var max = LunarUtil.HOU.length - 1;
|
|
|
|
|
var offset = Math.floor(days / 5);
|
|
|
|
|
if (offset > max) {
|
|
|
|
|
offset = max;
|
|
|
|
|
}
|
|
|
|
|
return name + ' ' + LunarUtil.HOU[offset];
|
|
|
|
|
},
|
|
|
|
|
getDayLu:function(){
|
|
|
|
|
var gan = LunarUtil.LU[this.getDayGan()];
|
|
|
|
|
@@ -1612,10 +1729,11 @@
|
|
|
|
|
getIndex:function(){
|
|
|
|
|
var firstDate = ExactDate.fromYmd(this._p.year,this._p.month,1);
|
|
|
|
|
var firstDayWeek = firstDate.getDay();
|
|
|
|
|
if(firstDayWeek===0){
|
|
|
|
|
firstDayWeek = 7;
|
|
|
|
|
var offset = firstDayWeek - this._p.start;
|
|
|
|
|
if(offset < 0) {
|
|
|
|
|
offset += 7;
|
|
|
|
|
}
|
|
|
|
|
return Math.ceil((this._p.day+firstDayWeek-this._p.start)/7);
|
|
|
|
|
return Math.ceil((this._p.day + offset)/7);
|
|
|
|
|
},
|
|
|
|
|
/**
|
|
|
|
|
* 周推移
|
|
|
|
|
@@ -2015,6 +2133,8 @@
|
|
|
|
|
jieQiJulianDays: []
|
|
|
|
|
},
|
|
|
|
|
getYear:function(){return this._p.year;},
|
|
|
|
|
getGanIndex:function(){return this._p.ganIndex;},
|
|
|
|
|
getZhiIndex:function(){return this._p.zhiIndex;},
|
|
|
|
|
getGan:function(){return LunarUtil.GAN[this._p.ganIndex+1];},
|
|
|
|
|
getZhi:function(){return LunarUtil.ZHI[this._p.zhiIndex+1];},
|
|
|
|
|
getGanZhi:function(){return this.getGan()+this.getZhi();},
|
|
|
|
|
@@ -2101,22 +2221,13 @@
|
|
|
|
|
return _YUN[Math.floor((this._p.year+2696)/20)%9]+'运';
|
|
|
|
|
},
|
|
|
|
|
getNineStar:function(){
|
|
|
|
|
var index = LunarUtil.getJiaZiIndex(this.getGanZhi())+1;
|
|
|
|
|
var n = 65;
|
|
|
|
|
switch(this.getYuan()){
|
|
|
|
|
case '中元':
|
|
|
|
|
n = 68;
|
|
|
|
|
break;
|
|
|
|
|
case '下元':
|
|
|
|
|
n = 62;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
var index = LunarUtil.getJiaZiIndex(this.getGanZhi()) + 1;
|
|
|
|
|
var yuan = Math.floor((this._p.year + 2696) / 60) % 3;
|
|
|
|
|
var offset = (62 + yuan * 3 - index) % 9;
|
|
|
|
|
if(0 === offset){
|
|
|
|
|
offset = 9;
|
|
|
|
|
}
|
|
|
|
|
var offset = (n-index)%9;
|
|
|
|
|
if(0===offset){
|
|
|
|
|
offset=9;
|
|
|
|
|
}
|
|
|
|
|
return NineStar.fromIndex(offset-1);
|
|
|
|
|
return NineStar.fromIndex(offset - 1);
|
|
|
|
|
},
|
|
|
|
|
getPositionXi:function(){
|
|
|
|
|
return LunarUtil.POSITION_XI[this._p.ganIndex+1];
|
|
|
|
|
@@ -2160,6 +2271,9 @@
|
|
|
|
|
toFullString:function(){
|
|
|
|
|
return this.getYear()+'年';
|
|
|
|
|
},
|
|
|
|
|
next:function(n){
|
|
|
|
|
return LunarYear.fromYear(this._p.year + n);
|
|
|
|
|
},
|
|
|
|
|
_compute:function(){
|
|
|
|
|
this._p.months = [];
|
|
|
|
|
this._p.jieQiJulianDays = [];
|
|
|
|
|
@@ -2300,6 +2414,79 @@
|
|
|
|
|
getPositionTaiSuiDesc:function(){
|
|
|
|
|
return LunarUtil.POSITION_DESC[this.getPositionTaiSui()];
|
|
|
|
|
},
|
|
|
|
|
getNineStar:function(){
|
|
|
|
|
var index = LunarYear.fromYear(this._p.year).getZhiIndex() % 3;
|
|
|
|
|
var m = this._p.month;
|
|
|
|
|
if (m < 0) {
|
|
|
|
|
m = -m;
|
|
|
|
|
}
|
|
|
|
|
var monthZhiIndex = (13 + m) % 12;
|
|
|
|
|
var n = 27 - (index * 3);
|
|
|
|
|
if (monthZhiIndex < LunarUtil.BASE_MONTH_ZHI_INDEX) {
|
|
|
|
|
n -= 3;
|
|
|
|
|
}
|
|
|
|
|
var offset = (n - monthZhiIndex) % 9;
|
|
|
|
|
return NineStar.fromIndex(offset);
|
|
|
|
|
},
|
|
|
|
|
next:function(n){
|
|
|
|
|
if (0 == n) {
|
|
|
|
|
return LunarMonth.fromYm(this._p.year, this._p.month);
|
|
|
|
|
} else {
|
|
|
|
|
var rest = Math.abs(n);
|
|
|
|
|
var ny = this._p.year;
|
|
|
|
|
var iy = ny;
|
|
|
|
|
var im = this._p.month;
|
|
|
|
|
var index = 0;
|
|
|
|
|
var months = LunarYear.fromYear(ny).getMonths();
|
|
|
|
|
var i;
|
|
|
|
|
var m;
|
|
|
|
|
var size;
|
|
|
|
|
if (n > 0) {
|
|
|
|
|
while (true) {
|
|
|
|
|
size = months.length;
|
|
|
|
|
for (i = 0; i < size; i++) {
|
|
|
|
|
m = months[i];
|
|
|
|
|
if (m.getYear() === iy && m.getMonth() === im) {
|
|
|
|
|
index = i;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
var more = size - index - 1;
|
|
|
|
|
if (rest < more) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
rest -= more;
|
|
|
|
|
var lastMonth = months[size - 1];
|
|
|
|
|
iy = lastMonth.getYear();
|
|
|
|
|
im = lastMonth.getMonth();
|
|
|
|
|
ny++;
|
|
|
|
|
months = LunarYear.fromYear(ny).getMonths();
|
|
|
|
|
}
|
|
|
|
|
return months[index + rest];
|
|
|
|
|
} else {
|
|
|
|
|
while (true) {
|
|
|
|
|
size = months.length;
|
|
|
|
|
for (i = 0; i < size; i++) {
|
|
|
|
|
m = months[i];
|
|
|
|
|
if (m.getYear() === iy && m.getMonth() === im) {
|
|
|
|
|
index = i;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (rest <= index) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
rest -= index;
|
|
|
|
|
var firstMonth = months[0];
|
|
|
|
|
iy = firstMonth.getYear();
|
|
|
|
|
im = firstMonth.getMonth();
|
|
|
|
|
ny--;
|
|
|
|
|
months = LunarYear.fromYear(ny).getMonths();
|
|
|
|
|
}
|
|
|
|
|
return months[index - rest];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
toString:function(){return this.getYear()+'年'+(this.isLeap()?'闰':'')+LunarUtil.MONTH[Math.abs(this.getMonth())]+'月('+this.getDayCount()+')天';}
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
@@ -2577,6 +2764,9 @@
|
|
|
|
|
days += this.getDaysOfMonth(year, i);
|
|
|
|
|
}
|
|
|
|
|
days += day;
|
|
|
|
|
if (1582 === year && 10 === month && day >= 15) {
|
|
|
|
|
days -= 10;
|
|
|
|
|
}
|
|
|
|
|
return days;
|
|
|
|
|
},
|
|
|
|
|
getWeeksOfMonth:function(year,month,start){
|
|
|
|
|
@@ -3345,10 +3535,8 @@
|
|
|
|
|
const startTimeZhiIndex = (start.getHour() === 23) ? 11 : LunarUtil.getTimeZhiIndex(start.toYmdHms().substr(11, 5));
|
|
|
|
|
// 时辰差
|
|
|
|
|
var hourDiff = endTimeZhiIndex - startTimeZhiIndex;
|
|
|
|
|
var endCalendar = ExactDate.fromYmd(end.getYear(), end.getMonth(), end.getDay());
|
|
|
|
|
var startCalendar = ExactDate.fromYmd(start.getYear(), start.getMonth(), start.getDay());
|
|
|
|
|
// 天数差
|
|
|
|
|
var dayDiff = Math.floor((endCalendar - startCalendar) / (1000 * 3600 * 24));
|
|
|
|
|
var dayDiff = ExactDate.getDaysBetweenYmd(start.getYear(), start.getMonth(), start.getDay(), end.getYear(), end.getMonth(), end.getDay());
|
|
|
|
|
if (hourDiff < 0) {
|
|
|
|
|
hourDiff += 12;
|
|
|
|
|
dayDiff--;
|
|
|
|
|
@@ -4126,7 +4314,7 @@
|
|
|
|
|
'冬至':'北方玄上玉宸天尊同黑帝五炁天君下降'
|
|
|
|
|
},
|
|
|
|
|
FESTIVAL: {
|
|
|
|
|
'1-1': [_f('天腊之辰', '天腊,此日五帝会于束方九炁青天')],
|
|
|
|
|
'1-1': [_f('天腊之辰', '天腊,此日五帝会于东方九炁青天')],
|
|
|
|
|
'1-3': [_f('郝真人圣诞'), _f('孙真人圣诞')],
|
|
|
|
|
'1-5': [_f('孙祖清静元君诞')],
|
|
|
|
|
'1-7': [_f('举迁赏会', '此日上元赐福,天官同地水二官考校罪福')],
|
|
|
|
|
@@ -4161,7 +4349,7 @@
|
|
|
|
|
'4-20': [_f('眼光圣母娘娘诞')],
|
|
|
|
|
'4-28': [_f('神农先帝诞')],
|
|
|
|
|
'5-1': [_f('南极长生大帝圣诞')],
|
|
|
|
|
'5-5': [_f('地腊之辰', '地腊,此日五帝会於南方三炁丹天'), _f('南方雷祖圣诞'), _f('地祗温元帅圣诞'), _f('雷霆邓天君圣诞')],
|
|
|
|
|
'5-5': [_f('地腊之辰', '地腊,此日五帝会于南方三炁丹天'), _f('南方雷祖圣诞'), _f('地祗温元帅圣诞'), _f('雷霆邓天君圣诞')],
|
|
|
|
|
'5-11': [_f('城隍爷圣诞')],
|
|
|
|
|
'5-13': [_f('关圣帝君降神'), _f('关平太子圣诞')],
|
|
|
|
|
'5-18': [_f('张天师圣诞')],
|
|
|
|
|
@@ -4203,7 +4391,7 @@
|
|
|
|
|
'9-22': [_f('增福财神诞')],
|
|
|
|
|
'9-23': [_f('萨翁真君圣诞')],
|
|
|
|
|
'9-28': [_f('五显灵官马元帅圣诞')],
|
|
|
|
|
'10-1': [_f('民岁腊之辰', '民岁腊,此日五帝会於北方五炁黑天'), _f('东皇大帝圣诞')],
|
|
|
|
|
'10-1': [_f('民岁腊之辰', '民岁腊,此日五帝会于北方五炁黑天'), _f('东皇大帝圣诞')],
|
|
|
|
|
'10-3': [_f('三茅应化真君圣诞')],
|
|
|
|
|
'10-6': [_f('天曹诸司五岳五帝圣诞')],
|
|
|
|
|
'10-15': [_f('下元水官大帝圣诞'), _f('建生大会', '此日下元解厄,水官同天地二官考校罪福')],
|
|
|
|
|
@@ -4214,7 +4402,7 @@
|
|
|
|
|
'11-9': [_f('湘子韩祖圣诞')],
|
|
|
|
|
'11-11': [_f('太乙救苦天尊圣诞')],
|
|
|
|
|
'11-26': [_f('北方五道圣诞')],
|
|
|
|
|
'12-8': [_f('王侯腊之辰', '王侯腊,此日五帝会於上方玄都玉京')],
|
|
|
|
|
'12-8': [_f('王侯腊之辰', '王侯腊,此日五帝会于上方玄都玉京')],
|
|
|
|
|
'12-16': [_f('南岳大帝圣诞'), _f('福德正神诞')],
|
|
|
|
|
'12-20': [_f('鲁班先师圣诞')],
|
|
|
|
|
'12-21': [_f('天猷上帝圣诞')],
|
|
|
|
|
|