Skip to content

Commit 32a9964

Browse files
committed
v1.3.5 修复闰月月相错误。
1 parent 1c4eddb commit 32a9964

File tree

6 files changed

+16
-21
lines changed

6 files changed

+16
-21
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,6 @@
101101
2. 新增:月相获取公历日、公历时刻。
102102
3. 优化:更新△T参数。
103103
4. 修复:农历闰月干支错误(应随上月)。
104+
105+
## [1.3.5] - 2025-09-30
106+
1. 修复:闰月月相错误。

src/culture/Phase.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ protected function __construct(int $lunarYear, int $lunarMonth, ?int $index = nu
3636
parent::__construct(static::$NAMES, $index);
3737
$m = LunarMonth::fromYm($lunarYear, $lunarMonth)->next(intdiv($index, $this->getSize()));
3838
$this->lunarYear = $m->getYear();
39-
$this->lunarMonth = $m->getMonth();
39+
$this->lunarMonth = $m->getMonthWithLeap();
4040
} else if ($name !== null) {
4141
parent::__construct(static::$NAMES, null, $name);
4242
$this->lunarYear = $lunarYear;
@@ -66,7 +66,7 @@ function next(int $n): static
6666
if ($i != 0) {
6767
$m = $m->next($i);
6868
}
69-
return static::fromIndex($m->getYear(), $m->getMonth(), $this->nextIndex($n));
69+
return static::fromIndex($m->getYear(), $m->getMonthWithLeap(), $this->nextIndex($n));
7070
}
7171

7272
function getStartSolarTime(): SolarTime

src/lunar/LunarDay.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,9 +296,9 @@ function getPhaseDay(): PhaseDay
296296
{
297297
$today = $this->getSolarDay();
298298
$m = $this->month->next(1);
299-
$p = Phase::fromIndex($m->getYear(), $m->getMonth(), 0);
299+
$p = Phase::fromIndex($m->getYear(), $m->getMonthWithLeap(), 0);
300300
$d = $p->getSolarDay();
301-
while ($p->getSolarDay()->isAfter($today)) {
301+
while ($d->isAfter($today)) {
302302
$p = $p->next(-1);
303303
$d = $p->getSolarDay();
304304
}

src/solar/SolarDay.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ function getRabByungDay(): RabByungDay
471471
function getPhaseDay(): PhaseDay
472472
{
473473
$month = $this->getLunarDay()->getLunarMonth()->next(1);
474-
$p = Phase::fromIndex($month->getYear(), $month->getMonth(), 0);
474+
$p = Phase::fromIndex($month->getYear(), $month->getMonthWithLeap(), 0);
475475
$d = $p->getSolarDay();
476476
while ($d->isAfter($this)) {
477477
$p = $p->next(-1);

src/solar/SolarTime.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ function getSixtyCycleHour(): SixtyCycleHour
296296
function getPhase(): Phase
297297
{
298298
$month = $this->getLunarHour()->getLunarDay()->getLunarMonth()->next(1);
299-
$p = Phase::fromIndex($month->getYear(), $month->getMonth(), 0);
299+
$p = Phase::fromIndex($month->getYear(), $month->getMonthWithLeap(), 0);
300300
while ($p->getSolarTime()->isAfter($this)) {
301301
$p = $p->next(-1);
302302
}

src/util/ShouXingUtil.php

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -390,8 +390,7 @@ static function eLon($t, $n)
390390
}
391391
$v /= static::$XL0[0];
392392
$t2 = $t * $t;
393-
$v += (-0.0728 - 2.7702 * $t - 1.1019 * $t2 - 0.0996 * $t2 * $t) / static::SECOND_PER_RAD;
394-
return $v;
393+
return $v + (-0.0728 - 2.7702 * $t - 1.1019 * $t2 - 0.0996 * $t2 * $t) / static::SECOND_PER_RAD;
395394
}
396395

397396
static function mLon($t, $n): float
@@ -433,8 +432,7 @@ static function mLon($t, $n): float
433432
}
434433
$v += $c * $tn;
435434
}
436-
$v /= static::SECOND_PER_RAD;
437-
return $v;
435+
return $v / static::SECOND_PER_RAD;
438436
}
439437

440438
static function gxcSunLon($t): float
@@ -493,8 +491,7 @@ static function dtT($t): float
493491
static function mv($t): float
494492
{
495493
$v = 8399.71 - 914 * sin(0.7848 + 8328.691425 * $t + 0.0001523 * $t * $t);
496-
$v -= 179 * sin(2.543 + 15542.7543 * $t) + 160 * sin(0.1874 + 7214.0629 * $t) + 62 * sin(3.14 + 16657.3828 * $t) + 34 * sin(4.827 + 16866.9323 * $t) + 22 * sin(4.9 + 23871.4457 * $t) + 12 * sin(2.59 + 14914.4523 * $t) + 7 * sin(0.23 + 6585.7609 * $t) + 5 * sin(0.9 + 25195.624 * $t) + 5 * sin(2.32 - 7700.3895 * $t) + 5 * sin(3.88 + 8956.9934 * $t) + 5 * sin(0.49 + 7771.3771 * $t);
497-
return $v;
494+
return $v - (179 * sin(2.543 + 15542.7543 * $t) + 160 * sin(0.1874 + 7214.0629 * $t) + 62 * sin(3.14 + 16657.3828 * $t) + 34 * sin(4.827 + 16866.9323 * $t) + 22 * sin(4.9 + 23871.4457 * $t) + 12 * sin(2.59 + 14914.4523 * $t) + 7 * sin(0.23 + 6585.7609 * $t) + 5 * sin(0.9 + 25195.624 * $t) + 5 * sin(2.32 - 7700.3895 * $t) + 5 * sin(3.88 + 8956.9934 * $t) + 5 * sin(0.49 + 7771.3771 * $t));
498495
}
499496

500497
static function saLonT($w): float
@@ -503,18 +500,15 @@ static function saLonT($w): float
503500
$t = ($w - 1.75347 - M_PI) / $v;
504501
$v = static::ev($t);
505502
$t += ($w - static::saLon($t, 10)) / $v;
506-
$v = static::ev($t);
507-
$t += ($w - static::saLon($t, -1)) / $v;
508-
return $t;
503+
return $t + (($w - static::saLon($t, -1)) / static::ev($t));
509504
}
510505

511506
static function saLonT2($w): float
512507
{
513508
$v = 628.3319653318;
514509
$t = ($w - 1.75347 - M_PI) / $v;
515510
$t -= (0.000005297 * $t * $t + 0.0334166 * cos(4.669257 + 628.307585 * $t) + 0.0002061 * cos(2.67823 + 628.307585 * $t) * $t) / $v;
516-
$t += ($w - static::eLon($t, 8) - M_PI + (20.5 + 17.2 * sin(2.1824 - 33.75705 * $t)) / static::SECOND_PER_RAD) / $v;
517-
return $t;
511+
return $t + (($w - static::eLon($t, 8) - M_PI + (20.5 + 17.2 * sin(2.1824 - 33.75705 * $t)) / static::SECOND_PER_RAD) / $v);
518512
}
519513

520514
static function msaLon($t, $mn, $sn): float
@@ -529,8 +523,7 @@ static function msaLonT($w): float
529523
$t += ($w - static::msaLon($t, 3, 3)) / $v;
530524
$v = static::mv($t) - static::ev($t);
531525
$t += ($w - static::msaLon($t, 20, 10)) / $v;
532-
$t += ($w - static::msaLon($t, -1, 60)) / $v;
533-
return $t;
526+
return $t + (($w - static::msaLon($t, -1, 60)) / $v);
534527
}
535528

536529
static function msaLonT2($w): float
@@ -541,8 +534,7 @@ static function msaLonT2($w): float
541534
$t -= (-0.00003309 * $t2 + 0.10976 * cos(0.784758 + 8328.6914246 * $t + 0.000152292 * $t2) + 0.02224 * cos(0.18740 + 7214.0628654 * $t - 0.00021848 * $t2) - 0.03342 * cos(4.669257 + 628.307585 * $t)) / $v;
542535
$l = static::mLon($t, 20) - (4.8950632 + 628.3319653318 * $t + 0.000005297 * $t * $t + 0.0334166 * cos(4.669257 + 628.307585 * $t) + 0.0002061 * cos(2.67823 + 628.307585 * $t) * $t + 0.000349 * cos(4.6261 + 1256.61517 * $t) - 20.5 / static::SECOND_PER_RAD);
543536
$v = 7771.38 - 914 * sin(0.7848 + 8328.691425 * $t + 0.0001523 * $t * $t) - 179 * sin(2.543 + 15542.7543 * $t) - 160 * sin(0.1874 + 7214.0629 * $t);
544-
$t += ($w - $l) / $v;
545-
return $t;
537+
return $t + ($w - $l) / $v;
546538
}
547539

548540
static function qiHigh($w): float

0 commit comments

Comments
 (0)