-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug_calendar.py
More file actions
37 lines (31 loc) · 1.17 KB
/
Copy pathdebug_calendar.py
File metadata and controls
37 lines (31 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
from datetime import datetime, timedelta
from lunar_python import Solar
def debug_dates():
# Check 1978-05-18
d1 = datetime(1978, 5, 18)
s1 = Solar.fromYmd(d1.year, d1.month, d1.day)
l1 = s1.getLunar()
print(f"1978-05-18: {l1.getYearInGanZhi()} {l1.getMonthInGanZhi()} {l1.getDayInGanZhi()}")
# Check for Bing Wu (Year 1978)
# Search whole year
curr = datetime(1978, 1, 1)
end = datetime(1978, 12, 31)
print("\nSearching for Bing Wu days in 1978:")
while curr < end:
s = Solar.fromYmd(curr.year, curr.month, curr.day)
l = s.getLunar()
if l.getDayInGanZhi() == '丙午':
print(f"FOUND Bing Wu: {curr.strftime('%Y-%m-%d')}")
curr += timedelta(days=1)
# Check for Ren Zi (Year 1990)
print("\nSearching for Ren Zi days in 1990:")
curr = datetime(1990, 1, 1)
end = datetime(1990, 12, 31)
while curr < end:
s = Solar.fromYmd(curr.year, curr.month, curr.day)
l = s.getLunar()
if l.getDayInGanZhi() == '壬子':
print(f"FOUND Ren Zi: {curr.strftime('%Y-%m-%d')}")
curr += timedelta(days=1)
if __name__ == "__main__":
debug_dates()