@@ -521,7 +521,7 @@ export class Phase extends LoopTyme {
521521 if ( typeof indexOrName === 'number' ) {
522522 const m : LunarMonth = LunarMonth . fromYm ( lunarYear , lunarMonth ) . next ( ~ ~ ( indexOrName / this . getSize ( ) ) ) ;
523523 this . lunarYear = m . getYear ( ) ;
524- this . lunarMonth = m . getMonth ( ) ;
524+ this . lunarMonth = m . getMonthWithLeap ( ) ;
525525 } else {
526526 this . lunarYear = Phase . numeric ( lunarYear , 'lunar year' ) ;
527527 this . lunarMonth = Phase . numeric ( lunarMonth , 'lunar month' ) ;
@@ -547,23 +547,24 @@ export class Phase extends LoopTyme {
547547 if ( i != 0 ) {
548548 m = m . next ( i ) ;
549549 }
550- return Phase . fromIndex ( m . getYear ( ) , m . getMonth ( ) , this . nextIndex ( n ) ) ;
550+ return Phase . fromIndex ( m . getYear ( ) , m . getMonthWithLeap ( ) , this . nextIndex ( n ) ) ;
551551 }
552552
553553 protected getStartSolarTime ( ) : SolarTime {
554554 const n : number = Math . floor ( ( this . lunarYear - 2000 ) * 365.2422 / 29.53058886 ) ;
555555 let i : number = 0 ;
556+ const jd : number = JulianDay . J2000 + ShouXingUtil . ONE_THIRD ;
556557 const d : SolarDay = LunarDay . fromYmd ( this . lunarYear , this . lunarMonth , 1 ) . getSolarDay ( ) ;
557558 while ( true ) {
558559 const t : number = ShouXingUtil . msaLonT ( ( n + i ) * ShouXingUtil . PI_2 ) * 36525 ;
559- if ( ! JulianDay . fromJulianDay ( t + JulianDay . J2000 + ShouXingUtil . ONE_THIRD - ShouXingUtil . dtT ( t ) ) . getSolarDay ( ) . isBefore ( d ) ) {
560+ if ( ! JulianDay . fromJulianDay ( jd + t - ShouXingUtil . dtT ( t ) ) . getSolarDay ( ) . isBefore ( d ) ) {
560561 break ;
561562 }
562563 i ++ ;
563564 }
564565 const r : number [ ] = [ 0 , 90 , 180 , 270 ] ;
565566 const t : number = ShouXingUtil . msaLonT ( ( n + i + r [ ~ ~ ( this . getIndex ( ) / 2 ) ] / 360.0 ) * ShouXingUtil . PI_2 ) * 36525 ;
566- return JulianDay . fromJulianDay ( t + JulianDay . J2000 + ShouXingUtil . ONE_THIRD - ShouXingUtil . dtT ( t ) ) . getSolarTime ( ) ;
567+ return JulianDay . fromJulianDay ( jd + t - ShouXingUtil . dtT ( t ) ) . getSolarTime ( ) ;
567568 }
568569
569570 getSolarTime ( ) : SolarTime {
@@ -2185,9 +2186,9 @@ export class LunarDay extends AbstractTyme {
21852186 getPhaseDay ( ) : PhaseDay {
21862187 const today : SolarDay = this . getSolarDay ( ) ;
21872188 const m : LunarMonth = this . month . next ( 1 ) ;
2188- let p : Phase = Phase . fromIndex ( m . getYear ( ) , m . getMonth ( ) , 0 ) ;
2189+ let p : Phase = Phase . fromIndex ( m . getYear ( ) , m . getMonthWithLeap ( ) , 0 ) ;
21892190 let d : SolarDay = p . getSolarDay ( ) ;
2190- while ( p . getSolarDay ( ) . isAfter ( today ) ) {
2191+ while ( d . isAfter ( today ) ) {
21912192 p = p . next ( - 1 ) ;
21922193 d = p . getSolarDay ( ) ;
21932194 }
@@ -3296,8 +3297,7 @@ export class ShouXingUtil {
32963297 }
32973298 v /= ShouXingUtil . XL0 [ 0 ] ;
32983299 const t2 : number = t * t ;
3299- v += ( - 0.0728 - 2.7702 * t - 1.1019 * t2 - 0.0996 * t2 * t ) / ShouXingUtil . SECOND_PER_RAD ;
3300- return v ;
3300+ return v + ( - 0.0728 - 2.7702 * t - 1.1019 * t2 - 0.0996 * t2 * t ) / ShouXingUtil . SECOND_PER_RAD ;
33013301 }
33023302
33033303 static mLon ( t : number , n : number ) : number {
@@ -3339,15 +3339,12 @@ export class ShouXingUtil {
33393339 }
33403340 v += c * tn ;
33413341 }
3342- v /= ShouXingUtil . SECOND_PER_RAD ;
3343- return v ;
3342+ return v / ShouXingUtil . SECOND_PER_RAD ;
33443343 }
33453344
33463345 static gxcSunLon ( t : number ) : number {
33473346 const t2 : number = t * t ;
3348- const v : number = - 0.043126 + 628.301955 * t - 0.000002732 * t2 ;
3349- const e : number = 0.016708634 - 0.000042037 * t - 0.0000001267 * t2 ;
3350- return - 20.49552 * ( 1 + e * Math . cos ( v ) ) / ShouXingUtil . SECOND_PER_RAD ;
3347+ return - 20.49552 * ( 1 + ( 0.016708634 - 0.000042037 * t - 0.0000001267 * t2 ) * Math . cos ( - 0.043126 + 628.301955 * t - 0.000002732 * t2 ) ) / ShouXingUtil . SECOND_PER_RAD ;
33513348 }
33523349
33533350 static ev ( t : number ) : number {
@@ -3392,19 +3389,16 @@ export class ShouXingUtil {
33923389 }
33933390
33943391 static mv ( t : number ) : number {
3395- let v : number = 8399.71 - 914 * Math . sin ( 0.7848 + 8328.691425 * t + 0.0001523 * t * t ) ;
3396- v -= 179 * Math . sin ( 2.543 + 15542.7543 * t ) + 160 * Math . sin ( 0.1874 + 7214.0629 * t ) + 62 * Math . sin ( 3.14 + 16657.3828 * t ) + 34 * Math . sin ( 4.827 + 16866.9323 * t ) + 22 * Math . sin ( 4.9 + 23871.4457 * t ) + 12 * Math . sin ( 2.59 + 14914.4523 * t ) + 7 * Math . sin ( 0.23 + 6585.7609 * t ) + 5 * Math . sin ( 0.9 + 25195.624 * t ) + 5 * Math . sin ( 2.32 - 7700.3895 * t ) + 5 * Math . sin ( 3.88 + 8956.9934 * t ) + 5 * Math . sin ( 0.49 + 7771.3771 * t ) ;
3397- return v ;
3392+ const v : number = 8399.71 - 914 * Math . sin ( 0.7848 + 8328.691425 * t + 0.0001523 * t * t ) ;
3393+ return v - ( 179 * Math . sin ( 2.543 + 15542.7543 * t ) + 160 * Math . sin ( 0.1874 + 7214.0629 * t ) + 62 * Math . sin ( 3.14 + 16657.3828 * t ) + 34 * Math . sin ( 4.827 + 16866.9323 * t ) + 22 * Math . sin ( 4.9 + 23871.4457 * t ) + 12 * Math . sin ( 2.59 + 14914.4523 * t ) + 7 * Math . sin ( 0.23 + 6585.7609 * t ) + 5 * Math . sin ( 0.9 + 25195.624 * t ) + 5 * Math . sin ( 2.32 - 7700.3895 * t ) + 5 * Math . sin ( 3.88 + 8956.9934 * t ) + 5 * Math . sin ( 0.49 + 7771.3771 * t ) ) ;
33983394 }
33993395
34003396 static saLonT ( w : number ) : number {
34013397 let t : number , v : number = 628.3319653318 ;
34023398 t = ( w - 1.75347 - Math . PI ) / v ;
34033399 v = ShouXingUtil . ev ( t ) ;
34043400 t += ( w - ShouXingUtil . saLon ( t , 10 ) ) / v ;
3405- v = ShouXingUtil . ev ( t ) ;
3406- t += ( w - ShouXingUtil . saLon ( t , - 1 ) ) / v ;
3407- return t ;
3401+ return t + ( w - ShouXingUtil . saLon ( t , - 1 ) ) / ShouXingUtil . ev ( t ) ;
34083402 }
34093403
34103404 static msaLon ( t : number , mn : number , sn : number ) : number {
@@ -3417,16 +3411,14 @@ export class ShouXingUtil {
34173411 t += ( w - ShouXingUtil . msaLon ( t , 3 , 3 ) ) / v ;
34183412 v = ShouXingUtil . mv ( t ) - ShouXingUtil . ev ( t ) ;
34193413 t += ( w - ShouXingUtil . msaLon ( t , 20 , 10 ) ) / v ;
3420- t += ( w - ShouXingUtil . msaLon ( t , - 1 , 60 ) ) / v ;
3421- return t ;
3414+ return t + ( w - ShouXingUtil . msaLon ( t , - 1 , 60 ) ) / v ;
34223415 }
34233416
34243417 static saLonT2 ( w : number ) : number {
34253418 const v : number = 628.3319653318 ;
34263419 let t : number = ( w - 1.75347 - Math . PI ) / v ;
34273420 t -= ( 0.000005297 * t * t + 0.0334166 * Math . cos ( 4.669257 + 628.307585 * t ) + 0.0002061 * Math . cos ( 2.67823 + 628.307585 * t ) * t ) / v ;
3428- t += ( w - ShouXingUtil . eLon ( t , 8 ) - Math . PI + ( 20.5 + 17.2 * Math . sin ( 2.1824 - 33.75705 * t ) ) / ShouXingUtil . SECOND_PER_RAD ) / v ;
3429- return t ;
3421+ return t + ( w - ShouXingUtil . eLon ( t , 8 ) - Math . PI + ( 20.5 + 17.2 * Math . sin ( 2.1824 - 33.75705 * t ) ) / ShouXingUtil . SECOND_PER_RAD ) / v ;
34303422 }
34313423
34323424 static msaLonT2 ( w : number ) : number {
@@ -3437,8 +3429,7 @@ export class ShouXingUtil {
34373429 t2 = t * t ;
34383430 const l : number = ShouXingUtil . mLon ( t , 20 ) - ( 4.8950632 + 628.3319653318 * t + 0.000005297 * t2 + 0.0334166 * Math . cos ( 4.669257 + 628.307585 * t ) + 0.0002061 * Math . cos ( 2.67823 + 628.307585 * t ) * t + 0.000349 * Math . cos ( 4.6261 + 1256.61517 * t ) - 20.5 / ShouXingUtil . SECOND_PER_RAD ) ;
34393431 v = 7771.38 - 914 * Math . sin ( 0.7848 + 8328.691425 * t + 0.0001523 * t2 ) - 179 * Math . sin ( 2.543 + 15542.7543 * t ) - 160 * Math . sin ( 0.1874 + 7214.0629 * t ) ;
3440- t += ( w - l ) / v ;
3441- return t ;
3432+ return t + ( w - l ) / v ;
34423433 }
34433434
34443435 static qiHigh ( w : number ) : number {
@@ -3501,12 +3492,11 @@ export class ShouXingUtil {
35013492 }
35023493 d -= 2451545 ;
35033494 } else if ( jd >= f2 && jd < f3 ) {
3495+ const n : number = ShouXingUtil . SB . charCodeAt ( Math . floor ( ( jd - f2 ) / 29.5306 ) ) ;
35043496 d = Math . floor ( ShouXingUtil . shuoLow ( Math . floor ( ( jd + pc - 2451551 ) / 29.5306 ) * ShouXingUtil . PI_2 ) + 0.5 ) ;
3505- const from : number = Math . floor ( ( jd - f2 ) / 29.5306 ) ;
3506- const n : string = ShouXingUtil . SB . substring ( from , from + 1 ) ;
3507- if ( '1' === n ) {
3497+ if ( 49 === n ) {
35083498 d += 1 ;
3509- } else if ( '2' === n ) {
3499+ } else if ( 50 === n ) {
35103500 d -= 1 ;
35113501 }
35123502 }
@@ -3538,11 +3528,10 @@ export class ShouXingUtil {
35383528 d -= 2451545 ;
35393529 } else if ( jd >= f2 && jd < f3 ) {
35403530 d = Math . floor ( ShouXingUtil . qiLow ( Math . floor ( ( jd + pc - 2451259 ) / 365.2422 * 24 ) * Math . PI / 12 ) + 0.5 ) ;
3541- const from : number = Math . floor ( ( jd - f2 ) / 365.2422 * 24 ) ;
3542- const n : string = ShouXingUtil . QB . substring ( from , from + 1 ) ;
3543- if ( '1' === n ) {
3531+ const n : number = ShouXingUtil . QB . charCodeAt ( Math . floor ( ( jd - f2 ) / 365.2422 * 24 ) ) ;
3532+ if ( 49 === n ) {
35443533 d += 1 ;
3545- } else if ( '2' === n ) {
3534+ } else if ( 50 === n ) {
35463535 d -= 1 ;
35473536 }
35483537 }
@@ -3563,7 +3552,6 @@ export class ShouXingUtil {
35633552 }
35643553 return a - jd < - 5 ? ShouXingUtil . qiAccurate ( w + d ) : a ;
35653554 }
3566-
35673555}
35683556
35693557export class SolarTerm extends LoopTyme {
@@ -4300,7 +4288,7 @@ export class SolarDay extends AbstractTyme {
43004288
43014289 getPhaseDay ( ) : PhaseDay {
43024290 const month : LunarMonth = this . getLunarDay ( ) . getLunarMonth ( ) . next ( 1 ) ;
4303- let p : Phase = Phase . fromIndex ( month . getYear ( ) , month . getMonth ( ) , 0 ) ;
4291+ let p : Phase = Phase . fromIndex ( month . getYear ( ) , month . getMonthWithLeap ( ) , 0 ) ;
43044292 let d : SolarDay = p . getSolarDay ( ) ;
43054293 while ( d . isAfter ( this ) ) {
43064294 p = p . next ( - 1 ) ;
@@ -4475,7 +4463,7 @@ export class SolarTime extends AbstractTyme {
44754463
44764464 getPhase ( ) : Phase {
44774465 const month : LunarMonth = this . getLunarHour ( ) . getLunarDay ( ) . getLunarMonth ( ) . next ( 1 ) ;
4478- let p : Phase = Phase . fromIndex ( month . getYear ( ) , month . getMonth ( ) , 0 ) ;
4466+ let p : Phase = Phase . fromIndex ( month . getYear ( ) , month . getMonthWithLeap ( ) , 0 ) ;
44794467 while ( p . getSolarTime ( ) . isAfter ( this ) ) {
44804468 p = p . next ( - 1 ) ;
44814469 }
0 commit comments