Skip to content

Commit d921a80

Browse files
committed
v1.3.1 新增藏历;优化代码。
1 parent 93950e2 commit d921a80

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+1171
-249
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,7 @@
8181
7. 废弃:大运的开始农历年、结束农历年(建议取开始干支年、结束干支年)。
8282
8. 废弃:小运的农历年(建议取干支年)。
8383
9. 修复:八字身宫计算错误的问题。
84+
85+
## [1.3.1] - 2025-05-09
86+
1. 新增:藏历。
87+
2. 优化:代码。

README.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Tyme [![License](https://img.shields.io/badge/license-MIT-4EB1BA.svg?style=flat-square)](https://github.com/6tail/tyme4php/blob/master/LICENSE)
22

3-
Tyme是一个非常强大的日历工具库,可以看作 [Lunar](https://6tail.cn/calendar/api.html "https://6tail.cn/calendar/api.html") 的升级版,拥有更优的设计和扩展性,支持公历和农历、星座、干支、生肖、节气、法定假日等。
3+
Tyme是一个非常强大的日历工具库,可以看作 [Lunar](https://6tail.cn/calendar/api.html "https://6tail.cn/calendar/api.html") 的升级版,拥有更优的设计和扩展性,支持公历、农历、藏历、星座、干支、生肖、节气、法定假日等。
44

55

66
> 基于php8.1开发。
@@ -19,7 +19,10 @@ Tyme是一个非常强大的日历工具库,可以看作 [Lunar](https://6tail
1919
2020
// 农历丙寅年四月廿一
2121
echo $solarDay->getLunarDay();
22-
22+
23+
// 第十七饶迥火虎年四月廿一
24+
echo $solarDay->getRabByungDay();
25+
2326
// 扩展方法
2427
SolarDay::extend('myMethod', function () {
2528
return sprintf('%04d-%02d-%02d', $this->getYear(), $this->getMonth(), $this->getDay());
@@ -44,11 +47,18 @@ Tyme是一个非常强大的日历工具库,可以看作 [Lunar](https://6tail
4447
4548
// 农历丙寅年四月廿一
4649
echo $solarDay->getLunarDay();
50+
51+
// 第十七饶迥火虎年四月廿一
52+
echo $solarDay->getRabByungDay();
4753

4854
## 文档
4955

5056
请移步至 [https://6tail.cn/tyme.html](https://6tail.cn/tyme.html "https://6tail.cn/tyme.html")
5157

5258
## Star History
5359

54-
[![Star History Chart](https://api.star-history.com/svg?repos=6tail/tyme4php&type=Date)](https://star-history.com/#6tail/tyme4php&Date)
60+
[![Star History Chart](https://api.star-history.com/svg?repos=6tail/tyme4php&type=Date)](https://star-history.com/#6tail/tyme4php&Date)
61+
62+
## 致谢
63+
1. 感谢许剑伟老师分享的寿星天文历,本项目节气算法引自 [https://github.com/sxwnl/sxwnl](https://github.com/sxwnl/sxwnl "https://github.com/sxwnl/sxwnl")
64+
2. 感谢[stonelf](https://github.com/stonelf "https://github.com/stonelf"),本项目藏历数据引自 [https://github.com/stonelf/zangli](https://github.com/stonelf/zangli "https://github.com/stonelf/zangli")

src/culture/Animal.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ class Animal extends LoopTyme
1717
protected function __construct(?int $index = null, ?string $name = null)
1818
{
1919
if ($index !== null) {
20-
parent::__construct(self::$NAMES, $index);
20+
parent::__construct(static::$NAMES, $index);
2121
} else if ($name !== null) {
22-
parent::__construct(self::$NAMES, null, $name);
22+
parent::__construct(static::$NAMES, null, $name);
2323
}
2424
}
2525

@@ -35,6 +35,6 @@ static function fromName(string $name): static
3535

3636
function next(int $n): static
3737
{
38-
return self::fromIndex($this->nextIndex($n));
38+
return static::fromIndex($this->nextIndex($n));
3939
}
4040
}

src/culture/Beast.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ class Beast extends LoopTyme
1717
protected function __construct(?int $index = null, ?string $name = null)
1818
{
1919
if ($index !== null) {
20-
parent::__construct(self::$NAMES, $index);
20+
parent::__construct(static::$NAMES, $index);
2121
} else if ($name !== null) {
22-
parent::__construct(self::$NAMES, null, $name);
22+
parent::__construct(static::$NAMES, null, $name);
2323
}
2424
}
2525

@@ -35,7 +35,7 @@ static function fromName(string $name): static
3535

3636
function next(int $n): static
3737
{
38-
return self::fromIndex($this->nextIndex($n));
38+
return static::fromIndex($this->nextIndex($n));
3939
}
4040

4141
/**

src/culture/Constellation.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ class Constellation extends LoopTyme
1717
protected function __construct(?int $index = null, ?string $name = null)
1818
{
1919
if ($index !== null) {
20-
parent::__construct(self::$NAMES, $index);
20+
parent::__construct(static::$NAMES, $index);
2121
} else if ($name !== null) {
22-
parent::__construct(self::$NAMES, null, $name);
22+
parent::__construct(static::$NAMES, null, $name);
2323
}
2424
}
2525

@@ -35,6 +35,6 @@ static function fromName(string $name): static
3535

3636
function next(int $n): static
3737
{
38-
return self::fromIndex($this->nextIndex($n));
38+
return static::fromIndex($this->nextIndex($n));
3939
}
4040
}

src/culture/Direction.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ class Direction extends LoopTyme
2020
protected function __construct(?int $index = null, ?string $name = null)
2121
{
2222
if ($index !== null) {
23-
parent::__construct(self::$NAMES, $index);
23+
parent::__construct(static::$NAMES, $index);
2424
} else if ($name !== null) {
25-
parent::__construct(self::$NAMES, null, $name);
25+
parent::__construct(static::$NAMES, null, $name);
2626
}
2727
}
2828

@@ -38,7 +38,7 @@ static function fromName(string $name): static
3838

3939
function next(int $n): static
4040
{
41-
return self::fromIndex($this->nextIndex($n));
41+
return static::fromIndex($this->nextIndex($n));
4242
}
4343

4444
/**

src/culture/Duty.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ class Duty extends LoopTyme
1717
protected function __construct(?int $index = null, ?string $name = null)
1818
{
1919
if ($index !== null) {
20-
parent::__construct(self::$NAMES, $index);
20+
parent::__construct(static::$NAMES, $index);
2121
} else if ($name !== null) {
22-
parent::__construct(self::$NAMES, null, $name);
22+
parent::__construct(static::$NAMES, null, $name);
2323
}
2424
}
2525

@@ -35,6 +35,6 @@ static function fromName(string $name): static
3535

3636
function next(int $n): static
3737
{
38-
return self::fromIndex($this->nextIndex($n));
38+
return static::fromIndex($this->nextIndex($n));
3939
}
4040
}

src/culture/Element.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ class Element extends LoopTyme
1717
protected function __construct(?int $index = null, ?string $name = null)
1818
{
1919
if ($index !== null) {
20-
parent::__construct(self::$NAMES, $index);
20+
parent::__construct(static::$NAMES, $index);
2121
} else if ($name !== null) {
22-
parent::__construct(self::$NAMES, null, $name);
22+
parent::__construct(static::$NAMES, null, $name);
2323
}
2424
}
2525

@@ -35,7 +35,7 @@ static function fromName(string $name): static
3535

3636
function next(int $n): static
3737
{
38-
return self::fromIndex($this->nextIndex($n));
38+
return static::fromIndex($this->nextIndex($n));
3939
}
4040

4141
/**

src/culture/God.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ class God extends LoopTyme
3333
protected function __construct(?int $index = null, ?string $name = null)
3434
{
3535
if ($index !== null) {
36-
parent::__construct(self::$NAMES, $index);
36+
parent::__construct(static::$NAMES, $index);
3737
} else if ($name !== null) {
38-
parent::__construct(self::$NAMES, null, $name);
38+
parent::__construct(static::$NAMES, null, $name);
3939
}
4040
}
4141

@@ -51,7 +51,7 @@ static function fromName(string $name): static
5151

5252
function next(int $n): static
5353
{
54-
return self::fromIndex($this->nextIndex($n));
54+
return static::fromIndex($this->nextIndex($n));
5555
}
5656

5757
/**

src/culture/KitchenGodSteed.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ static function fromLunarYear(int $lunarYear): KitchenGodSteed
3333

3434
protected function byHeavenStem(int $n): string
3535
{
36-
return self::$NUMBERS[$this->firstDaySixtyCycle->getHeavenStem()->stepsTo($n)];
36+
return static::$NUMBERS[$this->firstDaySixtyCycle->getHeavenStem()->stepsTo($n)];
3737
}
3838

3939
protected function byEarthBranch(int $n): string
4040
{
41-
return self::$NUMBERS[$this->firstDaySixtyCycle->getEarthBranch()->stepsTo($n)];
41+
return static::$NUMBERS[$this->firstDaySixtyCycle->getEarthBranch()->stepsTo($n)];
4242
}
4343

4444
/**

0 commit comments

Comments
 (0)