@@ -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 l y = 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 . getD ayInGanZhi( ) ) {
switch ( d ayInGanZhi) {
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 ) ;
} ,
getMonth NineStar : function ( ) {
var n = 12 ;
var yearZhi = this . getYearZhi ( ) ;
if ( '子午卯酉' . indexOf ( yearZhi ) > - 1 ) {
n = 18 ;
} else if ( '辰戌丑未' . indexOf ( yearZhi ) > - 1 ) {
n = 15 ;
getYear NineStar : 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 . _getMonth NineStar( 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 . getJ ieQi( );
return name . length > 0 ? this . _buildJieQi ( name , this . solar ) : null ;
for ( var key in this . _p . j ieQi) {
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 . from Ymd( 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 . getDaysBetween Ymd( 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 . star t) / 7 ) ;
return Math . ceil ( ( this . _p . day + offse t ) / 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 yua n = 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 * 3 600 * 24 ) ) ;
if ( hourDiff < 0 ) {
hourDiff + = 12 ;
dayDiff -- ;
var year ;
var month ;
var day ;
var hour = 0 ;
if ( 2 === sect ) {
var minutes = Math . floor ( ( end. get Calendar ( ) - start. get Calendar ( ) ) / 60000 ) ;
year = Math . floor ( minutes / 432 0) ;
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 ( '天猷上帝圣诞' ) ] ,