tyme4py 1.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. tyme4py-1.2.0/PKG-INFO +12 -0
  2. tyme4py-1.2.0/README.md +28 -0
  3. tyme4py-1.2.0/setup.cfg +4 -0
  4. tyme4py-1.2.0/setup.py +15 -0
  5. tyme4py-1.2.0/test/test_Constellation.py +22 -0
  6. tyme4py-1.2.0/test/test_Direction.py +15 -0
  7. tyme4py-1.2.0/test/test_DogDay.py +75 -0
  8. tyme4py-1.2.0/test/test_Duty.py +18 -0
  9. tyme4py-1.2.0/test/test_EarthBranch.py +31 -0
  10. tyme4py-1.2.0/test/test_Ecliptic.py +30 -0
  11. tyme4py-1.2.0/test/test_Eightchar.py +415 -0
  12. tyme4py-1.2.0/test/test_Element.py +20 -0
  13. tyme4py-1.2.0/test/test_Fetus.py +15 -0
  14. tyme4py-1.2.0/test/test_God.py +64 -0
  15. tyme4py-1.2.0/test/test_HeavenStem.py +36 -0
  16. tyme4py-1.2.0/test/test_HideHeavenStempy.py +28 -0
  17. tyme4py-1.2.0/test/test_JulianDay.py +9 -0
  18. tyme4py-1.2.0/test/test_LegalHoliday.py +45 -0
  19. tyme4py-1.2.0/test/test_LunarDay.py +113 -0
  20. tyme4py-1.2.0/test/test_LunarFestival.py +28 -0
  21. tyme4py-1.2.0/test/test_LunarHour.py +10 -0
  22. tyme4py-1.2.0/test/test_LunarMonth.py +170 -0
  23. tyme4py-1.2.0/test/test_LunarYear.py +83 -0
  24. tyme4py-1.2.0/test/test_NineDay.py +52 -0
  25. tyme4py-1.2.0/test/test_NineStar.py +67 -0
  26. tyme4py-1.2.0/test/test_Phenology.py +30 -0
  27. tyme4py-1.2.0/test/test_PlumRainDay.py +31 -0
  28. tyme4py-1.2.0/test/test_SixStar.py +30 -0
  29. tyme4py-1.2.0/test/test_Sixtycycle.py +35 -0
  30. tyme4py-1.2.0/test/test_SolarDay.py +59 -0
  31. tyme4py-1.2.0/test/test_SolarFestival.py +38 -0
  32. tyme4py-1.2.0/test/test_SolarHalfYear.py +30 -0
  33. tyme4py-1.2.0/test/test_SolarMonth.py +46 -0
  34. tyme4py-1.2.0/test/test_SolarSeason.py +12 -0
  35. tyme4py-1.2.0/test/test_SolarTerm.py +63 -0
  36. tyme4py-1.2.0/test/test_SolarTime.py +12 -0
  37. tyme4py-1.2.0/test/test_SolarYear.py +27 -0
  38. tyme4py-1.2.0/test/test_Taboo.py +55 -0
  39. tyme4py-1.2.0/test/test_Week.py +104 -0
  40. tyme4py-1.2.0/tyme4py/__init__.py +159 -0
  41. tyme4py-1.2.0/tyme4py/util/__init__.py +848 -0
  42. tyme4py-1.2.0/tyme4py.egg-info/PKG-INFO +12 -0
  43. tyme4py-1.2.0/tyme4py.egg-info/SOURCES.txt +43 -0
  44. tyme4py-1.2.0/tyme4py.egg-info/dependency_links.txt +1 -0
  45. tyme4py-1.2.0/tyme4py.egg-info/top_level.txt +1 -0
tyme4py-1.2.0/PKG-INFO ADDED
@@ -0,0 +1,12 @@
1
+ Metadata-Version: 2.1
2
+ Name: tyme4py
3
+ Version: 1.2.0
4
+ Summary: Tyme是一个非常强大的日历工具库,可以看作 Lunar 的升级版,拥有更优的设计和扩展性,支持公历和农历、星座、干支、生肖、节气、法定假日等。
5
+ Home-page: https://github.com/6tail/tyme4py
6
+ Author: 6tail
7
+ Author-email: 6tail@6tail.cn
8
+ License: MIT
9
+ Keywords: 公历 农历 儒略日 星座 干支 节气 法定假日
10
+ Requires-Python: >=3.8.9
11
+
12
+ Tyme是一个非常强大的日历工具库,可以看作 Lunar 的升级版,拥有更优的设计和扩展性,支持公历和农历、星座、干支、生肖、节气、法定假日等。
@@ -0,0 +1,28 @@
1
+ # Tyme [![License](https://img.shields.io/badge/license-MIT-4EB1BA.svg?style=flat-square)](https://github.com/6tail/tyme4py/blob/master/LICENSE)
2
+
3
+ Tyme是一个非常强大的日历工具库,可以看作 [Lunar](https://6tail.cn/calendar/api.html "https://6tail.cn/calendar/api.html") 的升级版,拥有更优的设计和扩展性,支持公历和农历、星座、干支、生肖、节气、法定假日等。
4
+
5
+ > 基于python3.8.9开发
6
+
7
+ ## 示例
8
+
9
+ $ pip install tyme4py
10
+
11
+ from tyme4py.solar import SolarDay
12
+
13
+ # 通过指定年月日初始化公历日
14
+ solar_day = SolarDay.from_ymd(1986, 5, 29)
15
+
16
+ # 1986年5月29日
17
+ print(solar_day.__str__())
18
+
19
+ # 农历丙寅年四月廿一
20
+ print(solar_day.get_lunar_day().__str__())
21
+
22
+ ## 文档
23
+
24
+ 请移步至 [https://6tail.cn/tyme.html](https://6tail.cn/tyme.html "https://6tail.cn/tyme.html")
25
+
26
+ ## Star History
27
+
28
+ [![Star History Chart](https://api.star-history.com/svg?repos=6tail/tyme4py&type=Date)](https://star-history.com/#6tail/tyme4py&Date)
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
tyme4py-1.2.0/setup.py ADDED
@@ -0,0 +1,15 @@
1
+ from setuptools import setup
2
+
3
+ setup(
4
+ name='tyme4py',
5
+ version='1.2.0',
6
+ description='Tyme是一个非常强大的日历工具库,可以看作 Lunar 的升级版,拥有更优的设计和扩展性,支持公历和农历、星座、干支、生肖、节气、法定假日等。',
7
+ long_description='Tyme是一个非常强大的日历工具库,可以看作 Lunar 的升级版,拥有更优的设计和扩展性,支持公历和农历、星座、干支、生肖、节气、法定假日等。',
8
+ packages=['tyme4py', 'tyme4py.util'],
9
+ url='https://github.com/6tail/tyme4py',
10
+ license='MIT',
11
+ author='6tail',
12
+ author_email='6tail@6tail.cn',
13
+ python_requires='>=3.8.9',
14
+ keywords='公历 农历 儒略日 星座 干支 节气 法定假日'
15
+ )
@@ -0,0 +1,22 @@
1
+ # -*- coding:utf-8 -*-
2
+ import unittest
3
+
4
+ from tyme4py.solar import SolarDay
5
+
6
+
7
+ class TestConstellation(unittest.TestCase):
8
+ def test(self):
9
+ assert SolarDay(2020, 3, 21).get_constellation().get_name() == '白羊'
10
+ assert SolarDay(2020, 4, 19).get_constellation().get_name() == '白羊'
11
+
12
+ def test1(self):
13
+ assert SolarDay(2020, 4, 20).get_constellation().get_name() == '金牛'
14
+ assert SolarDay(2020, 5, 20).get_constellation().get_name() == '金牛'
15
+
16
+ def test2(self):
17
+ assert SolarDay(2020, 5, 21).get_constellation().get_name() == '双子'
18
+ assert SolarDay(2020, 6, 21).get_constellation().get_name() == '双子'
19
+
20
+ def test3(self):
21
+ assert SolarDay(2020, 6, 22).get_constellation().get_name() == '巨蟹'
22
+ assert SolarDay(2020, 7, 22).get_constellation().get_name() == '巨蟹'
@@ -0,0 +1,15 @@
1
+ # -*- coding:utf-8 -*-
2
+ import unittest
3
+
4
+ from tyme4py.solar import SolarDay
5
+
6
+
7
+ class TestDirection(unittest.TestCase):
8
+ def test(self):
9
+ assert SolarDay(2021, 11, 13).get_lunar_day().get_sixty_cycle().get_heaven_stem().get_mascot_direction().get_name() == '东南'
10
+
11
+ def test1(self):
12
+ assert SolarDay(2024, 1, 1).get_lunar_day().get_sixty_cycle().get_heaven_stem().get_mascot_direction().get_name() == '东南'
13
+
14
+ def test2(self):
15
+ assert SolarDay(2023, 11, 6).get_lunar_day().get_jupiter_direction().get_name() == '东'
@@ -0,0 +1,75 @@
1
+ # -*- coding:utf-8 -*-
2
+ import unittest
3
+
4
+ from tyme4py.solar import SolarDay
5
+
6
+
7
+ class TestDogDay(unittest.TestCase):
8
+ def test(self):
9
+ d = SolarDay(2011, 7, 14).get_dog_day()
10
+ assert d
11
+ assert d.get_name() == '初伏'
12
+ assert d.get_dog().__str__() == '初伏'
13
+ assert d.__str__() == '初伏第1天'
14
+
15
+ def test1(self):
16
+ d = SolarDay(2011, 7, 23).get_dog_day()
17
+ assert d
18
+ assert d.get_name() == '初伏'
19
+ assert d.get_dog().__str__() == '初伏'
20
+ assert d.__str__() == '初伏第10天'
21
+
22
+ def test2(self):
23
+ d = SolarDay(2011, 7, 24).get_dog_day()
24
+ assert d
25
+ assert d.get_name() == '中伏'
26
+ assert d.get_dog().__str__() == '中伏'
27
+ assert d.__str__() == '中伏第1天'
28
+
29
+ def test3(self):
30
+ d = SolarDay(2011, 8, 12).get_dog_day()
31
+ assert d
32
+ assert d.get_name() == '中伏'
33
+ assert d.get_dog().__str__() == '中伏'
34
+ assert d.__str__() == '中伏第20天'
35
+
36
+ def test4(self):
37
+ d = SolarDay(2011, 8, 13).get_dog_day()
38
+ assert d
39
+ assert d.get_name() == '末伏'
40
+ assert d.get_dog().__str__() == '末伏'
41
+ assert d.__str__() == '末伏第1天'
42
+
43
+ def test5(self):
44
+ d = SolarDay(2011, 8, 22).get_dog_day()
45
+ assert d
46
+ assert d.get_name() == '末伏'
47
+ assert d.get_dog().__str__() == '末伏'
48
+ assert d.__str__() == '末伏第10天'
49
+
50
+ def test6(self):
51
+ assert SolarDay(2011, 7, 13).get_dog_day() is None
52
+
53
+ def test7(self):
54
+ assert SolarDay(2011, 8, 23).get_dog_day() is None
55
+
56
+ def test8(self):
57
+ d = SolarDay(2012, 7, 18).get_dog_day()
58
+ assert d
59
+ assert d.get_name() == '初伏'
60
+ assert d.get_dog().__str__() == '初伏'
61
+ assert d.__str__() == '初伏第1天'
62
+
63
+ def test9(self):
64
+ d = SolarDay(2012, 8, 5).get_dog_day()
65
+ assert d
66
+ assert d.get_name() == '中伏'
67
+ assert d.get_dog().__str__() == '中伏'
68
+ assert d.__str__() == '中伏第9天'
69
+
70
+ def test10(self):
71
+ d = SolarDay(2012, 8, 8).get_dog_day()
72
+ assert d
73
+ assert d.get_name() == '末伏'
74
+ assert d.get_dog().__str__() == '末伏'
75
+ assert d.__str__() == '末伏第2天'
@@ -0,0 +1,18 @@
1
+ # -*- coding:utf-8 -*-
2
+ import unittest
3
+
4
+ from tyme4py.solar import SolarDay
5
+
6
+
7
+ class TestDuty(unittest.TestCase):
8
+ def test(self):
9
+ assert SolarDay(2023, 10, 30).get_lunar_day().get_duty().get_name() == '闭'
10
+
11
+ def test1(self):
12
+ assert SolarDay(2023, 10, 19).get_lunar_day().get_duty().get_name() == '建'
13
+
14
+ def test2(self):
15
+ assert SolarDay(2023, 10, 7).get_lunar_day().get_duty().get_name() == '除'
16
+
17
+ def test3(self):
18
+ assert SolarDay(2023, 10, 8).get_lunar_day().get_duty().get_name() == '除'
@@ -0,0 +1,31 @@
1
+ # -*- coding:utf-8 -*-
2
+ import unittest
3
+
4
+ from tyme4py.sixtycycle import EarthBranch
5
+
6
+
7
+ class TestEarthBranch(unittest.TestCase):
8
+ def test(self):
9
+ assert EarthBranch(0).get_name() == '子'
10
+
11
+ def test1(self):
12
+ assert EarthBranch(0).get_index() == 0
13
+
14
+ def test2(self):
15
+ assert EarthBranch('子').get_opposite().get_name() == '午'
16
+ assert EarthBranch('戌').get_opposite().get_name() == '辰'
17
+
18
+ def test3(self):
19
+ assert EarthBranch('子').get_combine().get_name() == '丑'
20
+ assert EarthBranch('申').get_combine().get_name() == '巳'
21
+
22
+ def test4(self):
23
+ assert EarthBranch('巳').get_harm().get_name() == '寅'
24
+ assert EarthBranch('申').get_harm().get_name() == '亥'
25
+
26
+ def test5(self):
27
+ # 合化
28
+ assert EarthBranch('卯').combine(EarthBranch('戌')).get_name() == '火'
29
+ assert EarthBranch('戌').combine(EarthBranch('卯')).get_name() == '火'
30
+ # 卯子无法合化
31
+ assert EarthBranch('卯').combine(EarthBranch('子')) is None
@@ -0,0 +1,30 @@
1
+ # -*- coding:utf-8 -*-
2
+ import unittest
3
+
4
+ from tyme4py.solar import SolarDay
5
+
6
+
7
+ class TestEcliptic(unittest.TestCase):
8
+ def test(self):
9
+ star = SolarDay(2023, 10, 30).get_lunar_day().get_twelve_star()
10
+ assert star.get_name() == '天德'
11
+ assert star.get_ecliptic().get_name() == '黄道'
12
+ assert star.get_ecliptic().get_luck().get_name() == '吉'
13
+
14
+ def test1(self):
15
+ star = SolarDay(2023, 10, 19).get_lunar_day().get_twelve_star()
16
+ assert star.get_name() == '白虎'
17
+ assert star.get_ecliptic().get_name() == '黑道'
18
+ assert star.get_ecliptic().get_luck().get_name() == '凶'
19
+
20
+ def test2(self):
21
+ star = SolarDay(2023, 10, 7).get_lunar_day().get_twelve_star()
22
+ assert star.get_name() == '天牢'
23
+ assert star.get_ecliptic().get_name() == '黑道'
24
+ assert star.get_ecliptic().get_luck().get_name() == '凶'
25
+
26
+ def test3(self):
27
+ star = SolarDay(2023, 10, 8).get_lunar_day().get_twelve_star()
28
+ assert star.get_name() == '玉堂'
29
+ assert star.get_ecliptic().get_name() == '黄道'
30
+ assert star.get_ecliptic().get_luck().get_name() == '吉'
@@ -0,0 +1,415 @@
1
+ # -*- coding:utf-8 -*-
2
+ import unittest
3
+
4
+ from tyme4py.eightchar import EightChar, ChildLimit, Fortune, DecadeFortune
5
+ from tyme4py.eightchar.provider.impl import China95ChildLimitProvider, LunarSect2EightCharProvider, DefaultEightCharProvider, DefaultChildLimitProvider, LunarSect1ChildLimitProvider, LunarSect2ChildLimitProvider
6
+ from tyme4py.enums import Gender
7
+ from tyme4py.lunar import LunarHour
8
+ from tyme4py.sixtycycle import SixtyCycle, HeavenStem
9
+ from tyme4py.solar import SolarTime
10
+
11
+
12
+ class TestEightChar(unittest.TestCase):
13
+
14
+ def test1(self):
15
+ """十神"""
16
+ # 八字
17
+ eight_char: EightChar = EightChar(SixtyCycle('丙寅'), SixtyCycle('癸巳'), SixtyCycle('癸酉'), SixtyCycle('己未'))
18
+ # 年柱
19
+ year: SixtyCycle = eight_char.get_year()
20
+ # 月柱
21
+ month: SixtyCycle = eight_char.get_month()
22
+ # 日柱
23
+ day: SixtyCycle = eight_char.get_day()
24
+ # 时柱
25
+ hour: SixtyCycle = eight_char.get_hour()
26
+ # 日元(日主、日干)
27
+ me: HeavenStem = day.get_heaven_stem()
28
+ # 年柱天干十神
29
+ assert me.get_ten_star(year.get_heaven_stem()).get_name() == '正财'
30
+ # 月柱天干十神
31
+ assert me.get_ten_star(month.get_heaven_stem()).get_name() == '比肩'
32
+ # 时柱天干十神
33
+ assert me.get_ten_star(hour.get_heaven_stem()).get_name() == '七杀'
34
+ # 年柱地支十神(本气)
35
+ assert me.get_ten_star(year.get_earth_branch().get_hide_heaven_stem_main()).get_name() == '伤官'
36
+ # 年柱地支十神(中气)
37
+ assert year.get_earth_branch().get_hide_heaven_stem_middle()
38
+ assert me.get_ten_star(year.get_earth_branch().get_hide_heaven_stem_middle()).get_name() == '正财'
39
+ # 年柱地支十神(余气)
40
+ assert year.get_earth_branch().get_hide_heaven_stem_residual()
41
+ assert me.get_ten_star(year.get_earth_branch().get_hide_heaven_stem_residual()).get_name() == '正官'
42
+ # 日柱地支十神(本气)
43
+ assert me.get_ten_star(day.get_earth_branch().get_hide_heaven_stem_main()).get_name() == '偏印'
44
+ # 日柱地支藏干(中气)
45
+ assert day.get_earth_branch().get_hide_heaven_stem_middle() is None
46
+ # 日柱地支藏干(余气)
47
+ assert day.get_earth_branch().get_hide_heaven_stem_residual() is None
48
+ # 指定任意天干的十神
49
+ assert me.get_ten_star(HeavenStem('丙')).get_name() == '正财'
50
+
51
+ def test2(self):
52
+ """地势(长生十二神)"""
53
+ # 八字
54
+ eight_char: EightChar = EightChar(SixtyCycle('丙寅'), SixtyCycle('癸巳'), SixtyCycle('癸酉'), SixtyCycle('己未'))
55
+ # 年柱
56
+ year: SixtyCycle = eight_char.get_year()
57
+ # 月柱
58
+ month: SixtyCycle = eight_char.get_month()
59
+ # 日柱
60
+ day: SixtyCycle = eight_char.get_day()
61
+ # 时柱
62
+ hour: SixtyCycle = eight_char.get_hour()
63
+ # 日元(日主、日干)
64
+ me: HeavenStem = day.get_heaven_stem()
65
+ # 年柱地势
66
+ assert me.get_terrain(year.get_earth_branch()).get_name() == '沐浴'
67
+ # 月柱地势
68
+ assert me.get_terrain(month.get_earth_branch()).get_name() == '胎'
69
+ # 日柱地势
70
+ assert me.get_terrain(day.get_earth_branch()).get_name() == '病'
71
+ # 时柱地势
72
+ assert me.get_terrain(hour.get_earth_branch()).get_name() == '墓'
73
+
74
+ def test3(self):
75
+ """胎元 / 胎息 / 命宫"""
76
+ # 八字
77
+ eight_char: EightChar = EightChar(SixtyCycle('癸卯'), SixtyCycle('辛酉'), SixtyCycle('己亥'), SixtyCycle('癸酉'))
78
+ # 胎元
79
+ tai_yuan: SixtyCycle = eight_char.get_fetal_origin()
80
+ assert tai_yuan.get_name() == '壬子'
81
+ # 胎元纳音
82
+ assert tai_yuan.get_sound().get_name() == '桑柘木'
83
+
84
+ def test4(self):
85
+ """胎息"""
86
+ # 八字
87
+ eight_char: EightChar = EightChar(SixtyCycle('癸卯'), SixtyCycle('辛酉'), SixtyCycle('己亥'), SixtyCycle('癸酉'))
88
+ # 胎息
89
+ tai_xi: SixtyCycle = eight_char.get_fetal_breath()
90
+ assert tai_xi.get_name() == '甲寅'
91
+ # 胎息纳音
92
+ assert tai_xi.get_sound().get_name() == '大溪水'
93
+
94
+ def test5(self):
95
+ """命宫"""
96
+ # 八字
97
+ eight_char: EightChar = EightChar(SixtyCycle('癸卯'), SixtyCycle('辛酉'), SixtyCycle('己亥'), SixtyCycle('癸酉'))
98
+ # 命宫
99
+ ming_gong: SixtyCycle = eight_char.get_own_sign()
100
+ assert ming_gong.get_name() == '癸亥'
101
+ # 命宫纳音
102
+ assert ming_gong.get_sound().get_name() == '大海水'
103
+
104
+ def test6(self):
105
+ """身宫"""
106
+ # 八字
107
+ eight_char: EightChar = EightChar(SixtyCycle('癸卯'), SixtyCycle('辛酉'), SixtyCycle('己亥'), SixtyCycle('癸酉'))
108
+ # 身宫
109
+ shen_gong: SixtyCycle = eight_char.get_body_sign()
110
+ assert shen_gong.get_name() == '己未'
111
+ # 身宫纳音
112
+ assert shen_gong.get_sound().get_name() == '天上火'
113
+
114
+ def test7(self):
115
+ """地势(长生十二神)"""
116
+ # 八字
117
+ eight_char: EightChar = EightChar(SixtyCycle('乙酉'), SixtyCycle('戊子'), SixtyCycle('辛巳'), SixtyCycle('壬辰'))
118
+ # 日干
119
+ me: HeavenStem = eight_char.get_day().get_heaven_stem()
120
+ # 年柱地势
121
+ assert me.get_terrain(eight_char.get_year().get_earth_branch()).get_name() == '临官'
122
+ # 月柱地势
123
+ assert me.get_terrain(eight_char.get_month().get_earth_branch()).get_name() == '长生'
124
+ # 日柱地势
125
+ assert me.get_terrain(eight_char.get_day().get_earth_branch()).get_name() == '死'
126
+ # 时柱地势
127
+ assert me.get_terrain(eight_char.get_hour().get_earth_branch()).get_name() == '墓'
128
+
129
+ def test8(self):
130
+ """公历时刻转八字"""
131
+ eight_char: EightChar = SolarTime(2005, 12, 23, 8, 37, 0).get_lunar_hour().get_eight_char()
132
+ assert eight_char.get_year().get_name() == '乙酉'
133
+ assert eight_char.get_month().get_name() == '戊子'
134
+ assert eight_char.get_day().get_name() == '辛巳'
135
+ assert eight_char.get_hour().get_name() == '壬辰'
136
+
137
+ def test9(self):
138
+ eight_char: EightChar = SolarTime(1988, 2, 15, 23, 30, 0).get_lunar_hour().get_eight_char()
139
+ assert eight_char.get_year().get_name() == '戊辰'
140
+ assert eight_char.get_month().get_name() == '甲寅'
141
+ assert eight_char.get_day().get_name() == '辛丑'
142
+ assert eight_char.get_hour().get_name() == '戊子'
143
+
144
+ def test11(self):
145
+ """童限测试"""
146
+ child_limit: ChildLimit = ChildLimit(SolarTime(2022, 3, 9, 20, 51, 0), Gender.MAN)
147
+ assert child_limit.get_year_count() == 8
148
+ assert child_limit.get_month_count() == 9
149
+ assert child_limit.get_day_count() == 2
150
+ assert child_limit.get_hour_count() == 10
151
+ assert child_limit.get_minute_count() == 26
152
+ assert child_limit.get_end_time().__str__() == '2030年12月12日 07:17:00'
153
+
154
+ def test12(self):
155
+ """童限测试"""
156
+ child_limit: ChildLimit = ChildLimit(SolarTime(2018, 6, 11, 9, 30, 0), Gender.WOMAN)
157
+ assert child_limit.get_year_count() == 1
158
+ assert child_limit.get_month_count() == 9
159
+ assert child_limit.get_day_count() == 10
160
+ assert child_limit.get_hour_count() == 1
161
+ assert child_limit.get_minute_count() == 42
162
+ assert child_limit.get_end_time().__str__() == '2020年3月21日 11:12:00'
163
+
164
+ def test13(self):
165
+ """大运测试"""
166
+ # 童限
167
+ child_limit: ChildLimit = ChildLimit(SolarTime(1983, 2, 15, 20, 0, 0), Gender.WOMAN)
168
+ # 八字
169
+ assert child_limit.get_eight_char().__str__() == '癸亥 甲寅 甲戌 甲戌'
170
+ # 童限年数
171
+ assert child_limit.get_year_count() == 6
172
+ # 童限月数
173
+ assert child_limit.get_month_count() == 2
174
+ # 童限日数
175
+ assert child_limit.get_day_count() == 18
176
+ # 童限结束(即开始起运)的公历时刻
177
+ assert child_limit.get_end_time().__str__() == '1989年5月4日 18:24:00'
178
+ # 童限开始(即出生)的农历年干支
179
+ assert child_limit.get_start_time().get_lunar_hour().get_lunar_day().get_lunar_month().get_lunar_year().get_sixty_cycle().get_name() == '癸亥'
180
+ # 童限结束(即开始起运)的农历年干支
181
+ assert child_limit.get_end_time().get_lunar_hour().get_lunar_day().get_lunar_month().get_lunar_year().get_sixty_cycle().get_name() == '己巳'
182
+ # 第1轮大运
183
+ decadeFortune: DecadeFortune = child_limit.get_start_decade_fortune()
184
+ # 开始年龄
185
+ assert decadeFortune.get_start_age() == 7
186
+ # 结束年龄
187
+ assert decadeFortune.get_end_age() == 16
188
+ # 开始年
189
+ assert decadeFortune.get_start_lunar_year().get_year() == 1989
190
+ # 结束年
191
+ assert decadeFortune.get_end_lunar_year().get_year() == 1998
192
+ # 干支
193
+ assert decadeFortune.get_name() == '乙卯'
194
+ # 下一大运
195
+ assert decadeFortune.next(1).get_name() == '丙辰'
196
+ # 上一大运
197
+ assert decadeFortune.next(-1).get_name() == '甲寅'
198
+ # 第9轮大运
199
+ assert decadeFortune.next(8).get_name() == '癸亥'
200
+ # 小运
201
+ fortune: Fortune = child_limit.get_start_fortune()
202
+ # 年龄
203
+ assert fortune.get_age() == 7
204
+ # 农历年
205
+ assert fortune.get_lunar_year().get_year() == 1989
206
+ # 干支
207
+ assert fortune.get_name() == '辛巳'
208
+ # 流年
209
+ assert fortune.get_lunar_year().get_sixty_cycle().get_name() == '己巳'
210
+
211
+ def test14(self):
212
+ # 童限
213
+ child_limit: ChildLimit = ChildLimit(SolarTime(1992, 2, 2, 12, 0, 0), Gender.MAN)
214
+ # 八字
215
+ assert child_limit.get_eight_char().__str__() == '辛未 辛丑 戊申 戊午'
216
+ # 童限年数
217
+ assert child_limit.get_year_count() == 9
218
+ # 童限月数
219
+ assert child_limit.get_month_count() == 0
220
+ # 童限日数
221
+ assert child_limit.get_day_count() == 9
222
+ # 童限结束(即开始起运)的公历时刻
223
+ assert child_limit.get_end_time().__str__() == '2001年2月11日 18:58:00'
224
+ # 童限开始(即出生)的农历年干支
225
+ assert child_limit.get_start_time().get_lunar_hour().get_lunar_day().get_lunar_month().get_lunar_year().get_sixty_cycle().get_name() == '辛未'
226
+ # 童限结束(即开始起运)的农历年干支
227
+ assert child_limit.get_end_time().get_lunar_hour().get_lunar_day().get_lunar_month().get_lunar_year().get_sixty_cycle().get_name() == '辛巳'
228
+ # 第1轮大运
229
+ decadeFortune: DecadeFortune = child_limit.get_start_decade_fortune()
230
+ # 开始年龄
231
+ assert decadeFortune.get_start_age() == 10
232
+ # 结束年龄
233
+ assert decadeFortune.get_end_age() == 19
234
+ # 开始年
235
+ assert decadeFortune.get_start_lunar_year().get_year() == 2000
236
+ # 结束年
237
+ assert decadeFortune.get_end_lunar_year().get_year() == 2009
238
+ # 干支
239
+ assert decadeFortune.get_name() == '庚子'
240
+ # 下一大运
241
+ assert decadeFortune.next(1).get_name() == '己亥'
242
+ # 小运
243
+ fortune: Fortune = child_limit.get_start_fortune()
244
+ # 年龄
245
+ assert fortune.get_age() == 10
246
+ # 农历年
247
+ assert fortune.get_lunar_year().get_year() == 2000
248
+ # 干支
249
+ assert fortune.get_name() == '戊申'
250
+ # 小运推移
251
+ assert fortune.next(2).get_name() == '丙午'
252
+ assert fortune.next(-2).get_name() == '庚戌'
253
+ # 流年
254
+ assert fortune.get_lunar_year().get_sixty_cycle().get_name() == '庚辰'
255
+
256
+ def test15(self):
257
+ assert SolarTime(2018, 8, 8, 8, 8, 0).get_lunar_hour().get_eight_char().__str__() == '戊戌 庚申 壬申 甲辰'
258
+
259
+ def test16(self):
260
+ # 童限
261
+ child_limit: ChildLimit = ChildLimit(SolarTime(1990, 3, 15, 10, 30, 0), Gender.MAN)
262
+ # 八字
263
+ assert child_limit.get_eight_char().__str__() == '庚午 己卯 己卯 己巳'
264
+ # 童限年数
265
+ assert child_limit.get_year_count() == 6
266
+ # 童限月数
267
+ assert child_limit.get_month_count() == 11
268
+ # 童限日数
269
+ assert child_limit.get_day_count() == 23
270
+ # 童限结束(即开始起运)的公历时刻
271
+ assert child_limit.get_end_time().__str__() == '1997年3月11日 00:22:00'
272
+ # 小运
273
+ fortune: Fortune = child_limit.get_start_fortune()
274
+ # 年龄
275
+ assert fortune.get_age() == 8
276
+
277
+ def test17(self):
278
+ eight_char: EightChar = EightChar(SixtyCycle('己丑'), SixtyCycle('戊辰'), SixtyCycle('戊辰'), SixtyCycle('甲子'))
279
+ assert eight_char.get_own_sign().get_name() == '丁丑'
280
+
281
+ def test18(self):
282
+ eight_char: EightChar = EightChar(SixtyCycle('戊戌'), SixtyCycle('庚申'), SixtyCycle('丁亥'), SixtyCycle('丙午'))
283
+ assert eight_char.get_own_sign().get_name() == '乙卯'
284
+
285
+ def test19(self):
286
+ eight_char: EightChar = EightChar(SixtyCycle('甲子'), SixtyCycle('壬申'), SixtyCycle('庚子'), SixtyCycle('乙亥'))
287
+ assert eight_char.get_own_sign().get_name() == '甲戌'
288
+
289
+ def test20(self):
290
+ eight_char: EightChar = ChildLimit(SolarTime(2024, 1, 29, 9, 33, 0), Gender.MAN).get_eight_char()
291
+ assert eight_char.get_own_sign().get_name() == '癸亥'
292
+ assert eight_char.get_body_sign().get_name() == '己未'
293
+
294
+ def test21(self):
295
+ eight_char: EightChar = EightChar(SixtyCycle('辛亥'), SixtyCycle('乙未'), SixtyCycle('庚子'), SixtyCycle('甲辰'))
296
+ assert eight_char.get_body_sign().get_name() == '庚子'
297
+
298
+ def test22(self):
299
+ assert ChildLimit(SolarTime(1990, 1, 27, 0, 0, 0), Gender.MAN).get_eight_char().get_body_sign().get_name() == '丙寅'
300
+
301
+ def test23(self):
302
+ assert ChildLimit(SolarTime(2019, 3, 7, 8, 0, 0), Gender.MAN).get_eight_char().get_own_sign().get_name() == '甲戌'
303
+
304
+ def test24(self):
305
+ assert ChildLimit(SolarTime(2019, 3, 27, 2, 0, 0), Gender.MAN).get_eight_char().get_own_sign().get_name() == '丁丑'
306
+
307
+ def test25(self):
308
+ assert LunarHour(1994, 5, 20, 18, 0, 0).get_eight_char().get_own_sign().get_name() == '丙寅'
309
+
310
+ def test26(self):
311
+ assert SolarTime(1986, 5, 29, 13, 37, 0).get_lunar_hour().get_eight_char().get_body_sign().get_name() == '己丑'
312
+
313
+ def test27(self):
314
+ assert SolarTime(1994, 12, 6, 2, 0, 0).get_lunar_hour().get_eight_char().get_body_sign().get_name() == '乙丑'
315
+
316
+ def test28(self):
317
+ eight_char: EightChar = EightChar(SixtyCycle('辛亥'), SixtyCycle('丁酉'), SixtyCycle('丙午'), SixtyCycle('癸巳'))
318
+ assert eight_char.get_own_sign().get_name() == '辛卯'
319
+
320
+ def test29(self):
321
+ eight_char: EightChar = EightChar(SixtyCycle('丙寅'), SixtyCycle('庚寅'), SixtyCycle('辛卯'), SixtyCycle('壬辰'))
322
+ assert eight_char.get_own_sign().get_name() == '己亥'
323
+ assert eight_char.get_body_sign().get_name() == '乙未'
324
+
325
+ def test30(self):
326
+ assert EightChar('壬子', '辛亥', '壬戌', '乙巳').get_body_sign().get_name() == '乙巳'
327
+
328
+ def test31(self):
329
+ # 采用元亨利贞的起运算法
330
+ ChildLimit.provider = China95ChildLimitProvider()
331
+ # 童限
332
+ child_limit: ChildLimit = ChildLimit(SolarTime(1986, 5, 29, 13, 37, 0), Gender.MAN)
333
+ # 童限年数
334
+ assert child_limit.get_year_count() == 2
335
+ # 童限月数
336
+ assert child_limit.get_month_count() == 7
337
+ # 童限日数
338
+ assert child_limit.get_day_count() == 0
339
+ # 童限时数
340
+ assert child_limit.get_hour_count() == 0
341
+ # 童限分数
342
+ assert child_limit.get_minute_count() == 0
343
+ # 童限结束(即开始起运)的公历时刻
344
+ assert child_limit.get_end_time().__str__() == '1988年12月29日 13:37:00'
345
+ # 为了不影响其他测试用例,恢复默认起运算法
346
+ ChildLimit.provider = DefaultChildLimitProvider()
347
+
348
+ def test46(self):
349
+ LunarHour.provider = LunarSect2EightCharProvider()
350
+ eight_char: EightChar = EightChar(SixtyCycle('壬寅'), SixtyCycle('丙午'), SixtyCycle('己亥'), SixtyCycle('丙子'))
351
+ time_list: [str] = []
352
+ aa = eight_char.get_solar_times(1900, 2024)
353
+ for time in aa:
354
+ time_list.append(time.__str__())
355
+ assert time_list == ['1962年6月30日 23:00:00', '2022年6月15日 23:00:00']
356
+ LunarHour.provider = DefaultEightCharProvider()
357
+
358
+ def test47(self):
359
+ # 采用Lunar流派1的起运算法
360
+ ChildLimit.provider = LunarSect1ChildLimitProvider()
361
+ # 童限
362
+ child_limit: ChildLimit = ChildLimit(SolarTime(1986, 5, 29, 13, 37, 0), Gender.MAN)
363
+ # 童限年数
364
+ assert child_limit.get_year_count() == 2
365
+ # 童限月数
366
+ assert child_limit.get_month_count() == 7
367
+ # 童限日数
368
+ assert child_limit.get_day_count() == 0
369
+ # 童限时数
370
+ assert child_limit.get_hour_count() == 0
371
+ # 童限分数
372
+ assert child_limit.get_minute_count() == 0
373
+ # 童限结束(即开始起运)的公历时刻
374
+ assert child_limit.get_end_time().__str__() == '1988年12月29日 13:37:00'
375
+
376
+ # 为了不影响其他测试用例,恢复默认起运算法
377
+ ChildLimit.provider = DefaultChildLimitProvider()
378
+
379
+ def test48(self):
380
+ # 采用Lunar流派2的起运算法
381
+ ChildLimit.provider = LunarSect2ChildLimitProvider()
382
+ # 童限
383
+ child_limit: ChildLimit = ChildLimit(SolarTime(1986, 5, 29, 13, 37, 0), Gender.MAN)
384
+ # 童限年数
385
+ assert child_limit.get_year_count() == 2
386
+ # 童限月数
387
+ assert child_limit.get_month_count() == 7
388
+ # 童限日数
389
+ assert child_limit.get_day_count() == 0
390
+ # 童限时数
391
+ assert child_limit.get_hour_count() == 14
392
+ # 童限分数
393
+ assert child_limit.get_minute_count() == 0
394
+ # 童限结束(即开始起运)的公历时刻
395
+ assert child_limit.get_end_time().__str__() == '1988年12月30日 03:37:00'
396
+ # 为了不影响其他测试用例,恢复默认起运算法
397
+ ChildLimit.provider = DefaultChildLimitProvider()
398
+
399
+ def test49(self):
400
+ # 采用Lunar流派2的八字算法
401
+ LunarHour.provider = LunarSect2EightCharProvider()
402
+ # 童限
403
+ eight_char: EightChar = LunarHour(2001, 10, 18, 18, 0, 0).get_eight_char()
404
+ assert eight_char.get_name() == '辛巳 己亥 己亥 癸酉'
405
+ # 为了不影响其他测试用例,恢复默认八字算法
406
+ LunarHour.provider = DefaultEightCharProvider()
407
+
408
+ def test50(self):
409
+ # 采用Lunar流派2的八字算法
410
+ LunarHour.provider = LunarSect2EightCharProvider()
411
+ # 童限
412
+ eight_char: EightChar = LunarHour(2001, 10, 18, 18, 0, 0).get_eight_char()
413
+ assert eight_char.get_name() == '辛巳 己亥 己亥 癸酉'
414
+ # 为了不影响其他测试用例,恢复默认八字算法
415
+ LunarHour.provider = DefaultEightCharProvider()