1
0
mirror of synced 2026-04-16 13:28:39 +08:00

Compare commits

..

13 Commits

Author SHA1 Message Date
6tail
cde04a1993 v1.2.31 新增525心理健康节;修复出现多个全国中小学生安全教育日的问题;新增胎息。 2022-05-19 20:41:49 +08:00
6tail
69f0101c15 v1.2.30 新增万圣节、万圣节前夜;新增全国中小学生安全教育日;新增春社(原二月初二春社改为社日节)、秋社。 2022-04-03 10:38:19 +08:00
6tail
66d16db39e v1.2.29 每日宜忌支持2种流派。 2022-03-26 10:19:27 +08:00
6tail
98fb502c02 v1.2.28 支持获取当年第几周;支持2种流派获取起运。 2022-03-12 19:46:37 +08:00
6tail
44a2b408cf v1.2.27 新增阴历年、阴历月的推移;修复三候错误;修复道历节日错别字。 2022-02-16 20:02:38 +08:00
6tail
26557902f6 v1.2.26 修复SolarWeek获取当月第几周的错误。 2022-01-10 20:40:20 +08:00
6tail
1e7f33e048 v1.2.25 修复获取当前节气对象的阳历无时分秒的问题。 2022-01-08 16:42:06 +08:00
6tail
988d3f60a7 v1.2.24 修复获取当前节气对象报错的问题。 2022-01-08 10:19:13 +08:00
6tail
9bfb4ea312 v1.2.23 优化算法。 2022-01-07 20:31:14 +08:00
6tail
004899148d v1.2.22 修复九星错误;修复太岁方位错误。 2022-01-06 19:58:02 +08:00
6tail
c142ad7f6c v1.2.21 修复八字转阳历的错误;优化代码。 2022-01-02 17:31:31 +08:00
6tail
8d131aa31a Merge pull request #4 from Weidge/master
bug修复:反推八字Solar_fromBaZi函数,在阳历元旦后、农历新年前,反推失败的bug
2022-01-01 22:53:01 +08:00
Weidge
34469699a5 bug修复:反推八字Solar_fromBaZi函数,在阳历元旦后、农历新年前,反推失败的bug 2022-01-01 15:17:30 +08:00
9 changed files with 522 additions and 150 deletions

View File

@@ -147,3 +147,24 @@ test('身宫', () => {
const eightChar = lunar.getEightChar();
expect(eightChar.getShenGong()).toBe('壬午');
});
test('身宫1', () => {
const solar = Solar.fromYmdHms(1994, 12, 6, 2, 0, 0);
const lunar = solar.getLunar();
const eightChar = lunar.getEightChar();
expect(eightChar.getShenGong()).toBe('丁丑');
});
test('身宫2', () => {
const solar = Solar.fromYmdHms(1990, 12, 11, 6, 0, 0);
const lunar = solar.getLunar();
const eightChar = lunar.getEightChar();
expect(eightChar.getShenGong()).toBe('庚辰');
});
test('身宫3', () => {
const solar = Solar.fromYmdHms(1993, 5, 23, 4, 0, 0);
const lunar = solar.getLunar();
const eightChar = lunar.getEightChar();
expect(eightChar.getShenGong()).toBe('庚申');
});

View File

@@ -415,12 +415,12 @@ test('test022', () => {
test('test023', () => {
const lunar = Lunar.fromYmd(2022, 1, 1);
expect(lunar.getYearNineStar().toString()).toBe('五黄土玉衡');
expect(lunar.getYearNineStar().toString()).toBe('六白金开阳');
});
test('test024', () => {
const lunar = Lunar.fromYmd(2033, 1, 1);
expect(lunar.getYearNineStar().toString()).toBe('三碧木天');
expect(lunar.getYearNineStar().toString()).toBe('四绿木天');
});
test('test025', () => {
@@ -570,3 +570,23 @@ test('test052', () => {
const lunar = Solar.fromYmd(2011, 11, 12).getLunar();
expect(lunar.getDayPositionTai()).toBe('厕灶厨 外西南');
});
test('test053', () => {
const lunar = Solar.fromYmd(1722, 9, 25).getLunar();
expect(lunar.getOtherFestivals() + '').toBe('秋社');
});
test('test054', () => {
const lunar = Solar.fromYmd(840, 9, 14).getLunar();
expect(lunar.getOtherFestivals() + '').toBe('秋社');
});
test('test055', () => {
const lunar = Solar.fromYmd(2022, 3, 16).getLunar();
expect(lunar.getOtherFestivals() + '').toBe('春社');
});
test('test056', () => {
const lunar = Solar.fromYmd(2021, 3, 21).getLunar();
expect(lunar.getOtherFestivals() + '').toBe('春社');
});

View File

@@ -87,3 +87,8 @@ test('test17', () => {
const year = LunarYear.fromYear(2004);
expect(year.getYun()).toBe('八运');
});
test('test18', () => {
const year = LunarYear.fromYear(2022);
expect(year.getJieQiJulianDays()).toStrictEqual([2459555.7478605337, 2459570.499405936, 2459585.217980813, 2459599.9437018055, 2459614.7018054826, 2459629.5297495862, 2459644.446920318, 2459659.4814200983, 2459674.6389274267, 2459689.9334118855, 2459705.3512322665, 2459720.890569021, 2459736.517794922, 2459752.2178259823, 2459767.9429320656, 2459783.6713957503, 2459799.3534378354, 2459814.969435438, 2459830.480632029, 2459845.8774438635, 2459861.140466851, 2459876.2746654437, 2459891.281458942, 2459906.1807667296, 2459920.9903281447, 2459935.741672728, 2459950.461561025, 2459965.187040542, 2459979.9460747372, 2459994.7736723446, 2460009.6916930582]);
});

View File

@@ -31,3 +31,18 @@ test('9', () => {
test('10', () => {
expect(SolarUtil.isLeapYear(1500)).toBe(false);
});
test('11', () => {
var solar = Solar.fromYmd(2022, 3, 28);
expect(solar.getFestivals() + '').toBe('全国中小学生安全教育日');
});
test('12', () => {
var solar = Solar.fromYmd(2021, 3, 29);
expect(solar.getFestivals() + '').toBe('全国中小学生安全教育日');
});
test('13', () => {
var solar = Solar.fromYmd(1996, 3, 25);
expect(solar.getFestivals() + '').toBe('全国中小学生安全教育日');
});

View File

@@ -19,3 +19,21 @@ test('testFromSunday', () => {
expect(week.getFirstDay().toString()).toBe('2019-04-28');
expect(week.getFirstDayInMonth().toString()).toBe('2019-05-01');
});
test('test1', () => {
const start = 0;
const week = SolarWeek.fromYmd(2022, 5, 1, start);
expect(week.getIndex()).toBe(1);
});
test('test2', () => {
const start = 2;
const week = SolarWeek.fromYmd(2021, 5, 4, start);
expect(week.getIndex()).toBe(2);
});
test('test3', () => {
const start = 0;
const week = SolarWeek.fromYmd(2022, 3, 6, start);
expect(week.getIndexInYear()).toBe(11);
});

View File

@@ -77,3 +77,9 @@ test('test13', () => {
const lunar = solar.getLunar();
expect(lunar.getHou()).toBe('小寒 初候');
});
test('test14', () => {
const solar = Solar.fromYmd(2022,5,20);
const lunar = solar.getLunar();
expect(lunar.getHou()).toBe('立夏 三候');
});

View File

@@ -31,3 +31,30 @@ it('test3', () => {
expect(yun.getStartDay()).toBe(0);
expect(yun.getStartSolar().toYmd()).toBe('2020-02-06');
});
it('test4', () => {
const solar = Solar.fromYmdHms(2022, 3, 9, 20, 51, 0);
const lunar = solar.getLunar();
const eightChar = lunar.getEightChar();
const yun = eightChar.getYun(1);
expect(yun.getStartSolar().toYmd()).toBe('2030-12-19');
});
it('test5', () => {
const solar = Solar.fromYmdHms(2022, 3, 9, 20, 51, 0);
const lunar = solar.getLunar();
const eightChar = lunar.getEightChar();
const yun = eightChar.getYun(1, 2);
expect(yun.getStartYear()).toBe(8);
expect(yun.getStartMonth()).toBe(9);
expect(yun.getStartDay()).toBe(2);
expect(yun.getStartSolar().toYmd()).toBe('2030-12-12');
});
it('test6', () => {
const solar = Solar.fromYmdHms(2018, 6, 11, 9, 30, 0);
const lunar = solar.getLunar();
const eightChar = lunar.getEightChar();
const yun = eightChar.getYun(0, 2);
expect(yun.getStartSolar().toYmd()).toBe('2020-03-21');
});

554
lunar.js
View File

@@ -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());
}
};
})();
@@ -166,6 +163,12 @@
if(f){
l.push(f);
}
if (this._p.day + 7 > SolarUtil.getDaysOfMonth(this._p.year, this._p.month)) {
f = SolarUtil.WEEK_FESTIVAL[this._p.month + '-0-' + week];
if (f) {
l.push(f);
}
}
return l;
},
getOtherFestivals:function(){
@@ -304,7 +307,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 +369,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 +530,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 +776,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 +820,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();
@@ -846,13 +925,13 @@
return this.getDaySha();
},
getDayChong:function(){
return LunarUtil.CHONG[this.getDayZhi()];
return LunarUtil.CHONG[this._p.dayZhiIndex];
},
getDayChongGan:function(){
return LunarUtil.CHONG_GAN[this.getDayGan()];
return LunarUtil.CHONG_GAN[this._p.dayGanIndex];
},
getDayChongGanTie:function(){
return LunarUtil.CHONG_GAN_TIE[this.getDayGan()];
return LunarUtil.CHONG_GAN_TIE[this._p.dayGanIndex];
},
getDayChongShengXiao:function(){
var chong = this.getChong();
@@ -870,13 +949,13 @@
return LunarUtil.SHA[this.getDayZhi()];
},
getTimeChong:function(){
return LunarUtil.CHONG[this.getTimeZhi()];
return LunarUtil.CHONG[this._p.timeZhiIndex];
},
getTimeChongGan:function(){
return LunarUtil.CHONG_GAN[this.getTimeGan()];
return LunarUtil.CHONG_GAN[this._p.timeGanIndex];
},
getTimeChongGanTie:function(){
return LunarUtil.CHONG_GAN_TIE[this.getTimeGan()];
return LunarUtil.CHONG_GAN_TIE[this._p.timeGanIndex];
},
getTimeChongShengXiao:function(){
var chong = this.getTimeChong();
@@ -910,59 +989,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;
@@ -1008,9 +1079,28 @@
if(fs){
l=l.concat(fs);
}
if(this._p.solar.toYmd()===this._p.jieQi['清明'].next(-1).toYmd()){
var solarYmd = this._p.solar.toYmd();
if(this._p.solar.toYmd() === this._p.jieQi['清明'].next(-1).toYmd()){
l.push('寒食节');
}
var jq = this._p.jieQi['立春'];
var offset = 4 - jq.getLunar().getDayGanIndex();
if (offset < 0) {
offset += 10;
}
if (solarYmd === jq.next(offset + 40).toYmd()) {
l.push('春社');
}
jq = this._p.jieQi['立秋'];
offset = 4 - jq.getLunar().getDayGanIndex();
if (offset < 0) {
offset += 10;
}
if (solarYmd === jq.next(offset + 40).toYmd()) {
l.push('秋社');
}
return l;
},
getBaZi:function(){
@@ -1109,11 +1199,11 @@
}
return LunarUtil.POSITION_TAI_MONTH[m-1];
},
getDayYi:function(){
return LunarUtil.getDayYi(this.getMonthInGanZhiExact(),this.getDayInGanZhi());
getDayYi:function(sect){
return LunarUtil.getDayYi(2 == sect ? this.getMonthInGanZhiExact() : this.getMonthInGanZhi(), this.getDayInGanZhi());
},
getDayJi:function(){
return LunarUtil.getDayJi(this.getMonthInGanZhiExact(),this.getDayInGanZhi());
getDayJi:function(sect){
return LunarUtil.getDayJi(2 == sect ? this.getMonthInGanZhiExact() : this.getMonthInGanZhi(), this.getDayInGanZhi());
},
getDayJiShen:function(){
return LunarUtil.getDayJiShen(this.getMonth(),this.getDayInGanZhi());
@@ -1130,26 +1220,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 +1282,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 +1329,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 +1446,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 +1684,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 +1754,24 @@
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);
},
/**
* 获取当前日期是在当年第几周
* @return number 周序号从1开始
*/
getIndexInYear:function(){
var firstDate = ExactDate.fromYmd(this._p.year, 1, 1);
var firstDayWeek = firstDate.getDay();
var offset = firstDayWeek - this._p.start;
if(offset < 0) {
offset += 7;
}
return Math.ceil((SolarUtil.getDaysInYear(this._p.year, this._p.month, this._p.day) + offset)/7);
},
/**
* 周推移
@@ -2015,6 +2171,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 +2259,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 +2309,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 +2452,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()+')天';}
};
};
@@ -2556,9 +2781,9 @@
WEEK:['日','一','二','三','四','五','六'],
DAYS_OF_MONTH:[31,28,31,30,31,30,31,31,30,31,30,31],
XINGZUO:['白羊','金牛','双子','巨蟹','狮子','处女','天秤','天蝎','射手','摩羯','水瓶','双鱼'],
FESTIVAL:{'1-1':'元旦节','2-14':'情人节','3-8':'妇女节','3-12':'植树节','3-15':'消费者权益日','4-1':'愚人节','5-1':'劳动节','5-4':'青年节','6-1':'儿童节','7-1':'建党节','8-1':'建军节','9-10':'教师节','10-1':'国庆节','12-24':'平安夜','12-25':'圣诞节'},
OTHER_FESTIVAL:{'1-8':['周恩来逝世纪念日'],'1-10':['中国人民警察节','中国公安110宣传日'],'1-21':['列宁逝世纪念日'],'1-26':['国际海关日'],'2-2':['世界湿地日'],'2-4':['世界抗癌日'],'2-7':['京汉铁路罢工纪念'],'2-10':['国际气象节'],'2-19':['邓小平逝世纪念日'],'2-21':['国际母语日'],'2-24':['第三世界青年日'],'3-1':['国际海豹日'],'3-3':['全国爱耳日'],'3-5':['周恩来诞辰纪念日','中国青年志愿者服务日'],'3-6':['世界青光眼日'],'3-12':['孙中山逝世纪念日'],'3-14':['马克思逝世纪念日'],'3-17':['国际航海日'],'3-18':['全国科技人才活动日'],'3-21':['世界森林日','世界睡眠日'],'3-22':['世界水日'],'3-23':['世界气象日'],'3-24':['世界防治结核病日'],'4-2':['国际儿童图书日'],'4-7':['世界卫生日'],'4-22':['列宁诞辰纪念日'],'4-23':['世界图书和版权日'],'4-26':['世界知识产权日'],'5-3':['世界新闻自由日'],'5-5':['马克思诞辰纪念日'],'5-8':['世界红十字日'],'5-11':['世界肥胖日'],'5-27':['上海解放日'],'5-31':['世界无烟日'],'6-5':['世界环境日'],'6-6':['全国爱眼日'],'6-8':['世界海洋日'],'6-11':['中国人口日'],'6-14':['世界献血日'],'7-1':['香港回归纪念日'],'7-7':['中国人民抗日战争纪念日'],'7-11':['世界人口日'],'8-5':['恩格斯逝世纪念日'],'8-6':['国际电影节'],'8-12':['国际青年日'],'8-22':['邓小平诞辰纪念日'],'9-3':['中国抗日战争胜利纪念日'],'9-8':['世界扫盲日'],'9-9':['毛泽东逝世纪念日'],'9-14':['世界清洁地球日'],'9-18':['九一八事变纪念日'],'9-20':['全国爱牙日'],'9-21':['国际和平日'],'9-27':['世界旅游日'],'10-4':['世界动物日'],'10-10':['辛亥革命纪念日'],'10-13':['中国少年先锋队诞辰日'],'10-25':['抗美援朝纪念日'],'11-12':['孙中山诞辰纪念日'],'11-17':['国际大学生节'],'11-28':['恩格斯诞辰纪念日'],'12-1':['世界艾滋病日'],'12-12':['西安事变纪念日'],'12-13':['国家公祭日'],'12-26':['毛泽东诞辰纪念日']},
WEEK_FESTIVAL:{'5-2-0':'母亲节','6-3-0':'父亲节','11-4-4':'感恩节'},
FESTIVAL:{'1-1':'元旦节','2-14':'情人节','3-8':'妇女节','3-12':'植树节','3-15':'消费者权益日','4-1':'愚人节','5-1':'劳动节','5-4':'青年节','6-1':'儿童节','7-1':'建党节','8-1':'建军节','9-10':'教师节','10-1':'国庆节','10-31':'万圣节前夜','11-1':'万圣节','12-24':'平安夜','12-25':'圣诞节'},
OTHER_FESTIVAL:{'1-8':['周恩来逝世纪念日'],'1-10':['中国人民警察节','中国公安110宣传日'],'1-21':['列宁逝世纪念日'],'1-26':['国际海关日'],'2-2':['世界湿地日'],'2-4':['世界抗癌日'],'2-7':['京汉铁路罢工纪念'],'2-10':['国际气象节'],'2-19':['邓小平逝世纪念日'],'2-21':['国际母语日'],'2-24':['第三世界青年日'],'3-1':['国际海豹日'],'3-3':['全国爱耳日'],'3-5':['周恩来诞辰纪念日','中国青年志愿者服务日'],'3-6':['世界青光眼日'],'3-12':['孙中山逝世纪念日'],'3-14':['马克思逝世纪念日'],'3-17':['国际航海日'],'3-18':['全国科技人才活动日'],'3-21':['世界森林日','世界睡眠日'],'3-22':['世界水日'],'3-23':['世界气象日'],'3-24':['世界防治结核病日'],'4-2':['国际儿童图书日'],'4-7':['世界卫生日'],'4-22':['列宁诞辰纪念日'],'4-23':['世界图书和版权日'],'4-26':['世界知识产权日'],'5-3':['世界新闻自由日'],'5-5':['马克思诞辰纪念日'],'5-8':['世界红十字日'],'5-11':['世界肥胖日'],'5-25':['525心理健康节'],'5-27':['上海解放日'],'5-31':['世界无烟日'],'6-5':['世界环境日'],'6-6':['全国爱眼日'],'6-8':['世界海洋日'],'6-11':['中国人口日'],'6-14':['世界献血日'],'7-1':['香港回归纪念日'],'7-7':['中国人民抗日战争纪念日'],'7-11':['世界人口日'],'8-5':['恩格斯逝世纪念日'],'8-6':['国际电影节'],'8-12':['国际青年日'],'8-22':['邓小平诞辰纪念日'],'9-3':['中国抗日战争胜利纪念日'],'9-8':['世界扫盲日'],'9-9':['毛泽东逝世纪念日'],'9-14':['世界清洁地球日'],'9-18':['九一八事变纪念日'],'9-20':['全国爱牙日'],'9-21':['国际和平日'],'9-27':['世界旅游日'],'10-4':['世界动物日'],'10-10':['辛亥革命纪念日'],'10-13':['中国少年先锋队诞辰日'],'10-25':['抗美援朝纪念日'],'11-12':['孙中山诞辰纪念日'],'11-17':['国际大学生节'],'11-28':['恩格斯诞辰纪念日'],'12-1':['世界艾滋病日'],'12-12':['西安事变纪念日'],'12-13':['国家公祭日'],'12-26':['毛泽东诞辰纪念日']},
WEEK_FESTIVAL:{'3-0-1':'全国中小学生安全教育日','5-2-0':'母亲节','6-3-0':'父亲节','11-4-4':'感恩节'},
isLeapYear:function(year){return (year % 4 === 0 && year % 100 !== 0) || (year % 400 === 0);},
getDaysOfMonth:function(year,month){
var m = month-1;
@@ -2577,6 +2802,9 @@
days += this.getDaysOfMonth(year, i);
}
days += day;
if (1582 === year && 10 === month && day >= 15) {
days -= 10;
}
return days;
},
getWeeksOfMonth:function(year,month,start){
@@ -2630,12 +2858,13 @@
GONG:{'角':'东','井':'南','奎':'西','斗':'北','亢':'东','鬼':'南','娄':'西','牛':'北','氐':'东','柳':'南','胃':'西','女':'北','房':'东','星':'南','昴':'西','虚':'北','心':'东','张':'南','毕':'西','危':'北','尾':'东','翼':'南','觜':'西','室':'北','箕':'东','轸':'南','参':'西','壁':'北' },
SHOU:{'东':'青龙','南':'朱雀','西':'白虎','北':'玄武'},
FESTIVAL:{'1-1':'春节','1-15':'元宵节','2-2':'龙头节','5-5':'端午节','7-7':'七夕节','8-15':'中秋节','9-9':'重阳节','12-8':'腊八节'},
OTHER_FESTIVAL:{'1-4':['接神日'],'1-5':['隔开日'],'1-7':['人日'],'1-8':['谷日','顺星节'],'1-9':['天日'],'1-10':['地日'],'1-20':['天穿节'],'1-25':['填仓节'],'1-30':['正月晦'],'2-1':['中和节'],'2-2':['社'],'3-3':['上巳节'],'5-20':['分龙节'],'5-25':['会龙节'],'6-6':['天贶节'],'6-24':['观莲节'],'6-25':['五谷母节'],'7-14':['中元节'],'7-22':['财神节'],'7-29':['地藏节'],'8-1':['天灸日'],'10-1':['寒衣节'],'10-10':['十成节'],'10-15':['下元节'],'12-7':['驱傩日'],'12-16':['尾牙'],'12-24':['祭灶日']},
CHONG:{'子':'午','丑':'未','寅':'申','卯':'酉','辰':'戌','巳':'亥','午':'子','未':'丑','申':'寅','酉':'卯','戌':'辰','亥':'巳'},
CHONG_GAN:{'甲':'戊','乙':'己','丙':'庚','丁':'辛','戊':'壬','己':'癸','庚':'甲','辛':'乙','壬':'丙','癸':'丁'},
CHONG_GAN_BAD:{'':'','辛':'','壬':'','':'丁'},
CHONG_GAN_TIE:{'甲':'己','乙':'','丙':'辛','丁':'庚','戊':'癸','己':'壬','庚':'乙','辛':'甲','壬':'丁','':''},
CHONG_GAN_TIE_GOOD:{'甲':'己','':'辛','':'癸','':'乙','':'丁'},
OTHER_FESTIVAL:{'1-4':['接神日'],'1-5':['隔开日'],'1-7':['人日'],'1-8':['谷日','顺星节'],'1-9':['天日'],'1-10':['地日'],'1-20':['天穿节'],'1-25':['填仓节'],'1-30':['正月晦'],'2-1':['中和节'],'2-2':['社日节'],'3-3':['上巳节'],'5-20':['分龙节'],'5-25':['会龙节'],'6-6':['天贶节'],'6-24':['观莲节'],'6-25':['五谷母节'],'7-14':['中元节'],'7-22':['财神节'],'7-29':['地藏节'],'8-1':['天灸日'],'10-1':['寒衣节'],'10-10':['十成节'],'10-15':['下元节'],'12-7':['驱傩日'],'12-16':['尾牙'],'12-24':['祭灶日']},
CHONG:['午','未','申','酉','戌','亥','子','丑','寅','卯','辰','巳'],
CHONG_GAN:['戊','己','庚','辛','壬','癸','甲','乙','丙','丁'],
CHONG_GAN_TIE:['','','辛','庚','癸','壬','','','丁','丙'],
CHONG_GAN_4:['','辛','壬','癸','','','甲','乙','',''],
HE_GAN_5:['己','','辛','','癸','','乙','','丁','戊'],
HE_ZHI_6:['丑','子','亥','戌','酉','申','未','午','巳','辰','卯','寅'],
SHA:{'子':'南','丑':'东','寅':'北','卯':'西','辰':'南','巳':'东','午':'北','未':'西','申':'南','酉':'东','戌':'北','亥':'西'},
POSITION_DESC:{'坎':'正北','艮':'东北','震':'正东','巽':'东南','离':'正南','坤':'西南','兑':'正西','乾':'西北','中':'中宫'},
NAYIN:{'甲子':'海中金','甲午':'沙中金','丙寅':'炉中火','丙申':'山下火','戊辰':'大林木','戊戌':'平地木','庚午':'路旁土','庚子':'壁上土','壬申':'剑锋金','壬寅':'金箔金','甲戌':'山头火','甲辰':'覆灯火','丙子':'涧下水','丙午':'天河水','戊寅':'城头土','戊申':'大驿土','庚辰':'白蜡金','庚戌':'钗钏金','壬午':'杨柳木','壬子':'桑柘木','甲申':'泉中水','甲寅':'大溪水','丙戌':'屋上土','丙辰':'沙中土','戊子':'霹雳火','戊午':'天上火','庚寅':'松柏木','庚申':'石榴木','壬辰':'长流水','壬戌':'大海水','乙丑':'海中金','乙未':'沙中金','丁卯':'炉中火','丁酉':'山下火','己巳':'大林木','己亥':'平地木','辛未':'路旁土','辛丑':'壁上土','癸酉':'剑锋金','癸卯':'金箔金','乙亥':'山头火','乙巳':'覆灯火','丁丑':'涧下水','丁未':'天河水','己卯':'城头土','己酉':'大驿土','辛巳':'白蜡金','辛亥':'钗钏金','癸未':'杨柳木','癸丑':'桑柘木','乙酉':'泉中水','乙卯':'大溪水','丁亥':'屋上土','丁巳':'沙中土','己丑':'霹雳火','己未':'天上火','辛卯':'松柏木','辛酉':'石榴木','癸巳':'长流水','癸亥':'大海水'},
@@ -3280,6 +3509,13 @@
return LunarUtil.GAN[ganIndex+1]+LunarUtil.ZHI[zhiIndex+1];
},
getTaiYuanNaYin:function(){return LunarUtil.NAYIN[this.getTaiYuan()];},
getTaiXi:function(){
var lunar = this._p.lunar;
var ganIndex = (2 == sect) ? lunar.getDayGanIndexExact2() : lunar.getDayGanIndexExact();
var zhiIndex = (2 == sect) ? lunar.getDayZhiIndexExact2() : lunar.getDayZhiIndexExact();
return LunarUtil.HE_GAN_5[ganIndex]+LunarUtil.HE_ZHI_6[zhiIndex];
},
getTaiXiNaYin:function(){return LunarUtil.NAYIN[this.getTaiXi()];},
getMingGong:function(){
var monthZhiIndex = 0;
var timeZhiIndex = 0;
@@ -3318,8 +3554,11 @@
timeZhiIndex = i;
}
}
var zhiIndex = (2 + (monthZhiIndex+timeZhiIndex))%12;
var jiaZiIndex = LunarUtil.getJiaZiIndex(lunar.getMonthInGanZhiExact()) - (monthZhiIndex-zhiIndex);
var zhiIndex = 2 + monthZhiIndex + timeZhiIndex;
if (zhiIndex > 12) {
zhiIndex -= 12;
}
var jiaZiIndex = LunarUtil.getJiaZiIndex(lunar.getMonthInGanZhiExact()) - (monthZhiIndex - zhiIndex);
if(jiaZiIndex>=60){
jiaZiIndex -= 60;
}
@@ -3330,7 +3569,8 @@
},
getShenGongNaYin:function(){return LunarUtil.NAYIN[this.getShenGong()];},
getLunar:function(){return this._p.lunar;},
getYun:function(gender){
getYun:function(gender, sect){
sect = (2 == sect) ? sect : 1;
var lunar = this.getLunar();
var yang = 0 === lunar.getYearGanIndexExact() % 2;
var man = 1 === gender;
@@ -3341,27 +3581,44 @@
var current = lunar.getSolar();
var start = forward ? current : prev.getSolar();
var end = forward ? next.getSolar() : current;
const endTimeZhiIndex = (end.getHour() === 23) ? 11 : LunarUtil.getTimeZhiIndex(end.toYmdHms().substr(11, 5));
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));
if (hourDiff < 0) {
hourDiff += 12;
dayDiff--;
var year;
var month;
var day;
var hour = 0;
if (2 === sect) {
var minutes = Math.floor((end.getCalendar() - start.getCalendar()) / 60000);
year = Math.floor(minutes / 4320);
minutes -= year * 4320;
month = Math.floor(minutes / 360);
minutes -= month * 360;
day = Math.floor(minutes / 12);
minutes -= day * 12;
hour = minutes * 2;
} else {
var endTimeZhiIndex = (end.getHour() === 23) ? 11 : LunarUtil.getTimeZhiIndex(end.toYmdHms().substr(11, 5));
var startTimeZhiIndex = (start.getHour() === 23) ? 11 : LunarUtil.getTimeZhiIndex(start.toYmdHms().substr(11, 5));
// 时辰差
var hourDiff = endTimeZhiIndex - startTimeZhiIndex;
// 天数差
var dayDiff = ExactDate.getDaysBetweenYmd(start.getYear(), start.getMonth(), start.getDay(), end.getYear(), end.getMonth(), end.getDay());
if (hourDiff < 0) {
hourDiff += 12;
dayDiff--;
}
var monthDiff = Math.floor(hourDiff * 10 / 30);
month = dayDiff * 4 + monthDiff;
day = hourDiff * 10 - monthDiff * 30;
year = Math.floor(month / 12);
month = month - year * 12;
}
var monthDiff = Math.floor(hourDiff * 10 / 30);
var month = dayDiff * 4 + monthDiff;
var day = hourDiff * 10 - monthDiff * 30;
var year = Math.floor(month / 12);
month = month - year * 12;
return {
year: year,
month: month,
day: day
day: day,
hour: hour
};
})();
var buildLiuYue = function(liuNian, index){
@@ -3541,6 +3798,7 @@
startYear: start.year,
startMonth: start.month,
startDay: start.day,
startHour: start.hour,
forward: forward,
lunar: lunar
},
@@ -3548,6 +3806,7 @@
getStartYear: function(){return this._p.startYear;},
getStartMonth: function(){return this._p.startMonth;},
getStartDay: function(){return this._p.startDay;},
getStartHour: function(){return this._p.startHour;},
isForward: function(){return this._p.forward;},
getLunar: function(){return this._p.lunar;},
getStartSolar: function(){
@@ -3556,6 +3815,7 @@
c.setFullYear(birth.getYear() + this._p.startYear);
c.setMonth(birth.getMonth()-1+this._p.startMonth);
c.setDate(birth.getDay() + this._p.startDay);
c.setHours(birth.getHour() + this._p.startHour);
return Solar.fromDate(c);
},
getDaYun: function(n){
@@ -3612,7 +3872,7 @@
},
getTianShenType:function(){return LunarUtil.TIAN_SHEN_TYPE[this.getTianShen()];},
getTianShenLuck:function(){return LunarUtil.TIAN_SHEN_TYPE_LUCK[this.getTianShenType()];},
getChong:function(){return LunarUtil.CHONG[this.getZhi()];},
getChong:function(){return LunarUtil.CHONG[this._p.zhiIndex];},
getSha:function(){return LunarUtil.SHA[this.getZhi()];},
getChongShengXiao:function(){
var chong = this.getChong();
@@ -3624,8 +3884,8 @@
return '';
},
getChongDesc:function(){return '(' + this.getChongGan() + this.getChong() + ')' + this.getChongShengXiao();},
getChongGan:function(){return LunarUtil.CHONG_GAN[this.getGan()];},
getChongGanTie:function(){return LunarUtil.CHONG_GAN_TIE[this.getGan()];},
getChongGan:function(){return LunarUtil.CHONG_GAN[this._p.ganIndex];},
getChongGanTie:function(){return LunarUtil.CHONG_GAN_TIE[this._p.ganIndex];},
getYi:function(){return LunarUtil.getTimeYi(this._p.lunar.getDayInGanZhiExact(), this.getGanZhi());},
getJi:function(){return LunarUtil.getTimeJi(this._p.lunar.getDayInGanZhiExact(), this.getGanZhi());},
getNineStar:function(){
@@ -4126,7 +4386,7 @@
'冬至':'北方玄上玉宸天尊同黑帝五炁天君下降'
},
FESTIVAL: {
'1-1': [_f('天腊之辰', '天腊,此日五帝会于方九炁青天')],
'1-1': [_f('天腊之辰', '天腊,此日五帝会于方九炁青天')],
'1-3': [_f('郝真人圣诞'), _f('孙真人圣诞')],
'1-5': [_f('孙祖清静元君诞')],
'1-7': [_f('举迁赏会', '此日上元赐福,天官同地水二官考校罪福')],
@@ -4161,7 +4421,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 +4463,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 +4474,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('天猷上帝圣诞')],

View File

@@ -1,6 +1,6 @@
{
"name": "lunar-javascript",
"version": "1.2.20",
"version": "1.2.31",
"description": "lunar is a calendar library for Solar and Chinese Lunar.",
"main": "index.js",
"scripts": {