forked from OPN48/cnlunar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsolar24.py
31 lines (27 loc) · 909 Bytes
/
solar24.py
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
# 24节气模块\节气数据16进制加解密
# author: cuba3
# github: https://github.com/cuba3/pyGregorian2LunarCalendar
from config import solarTermsData, START_YEAR
from tools import abListMerge
# 解压缩16进制用
def unZipSolarTermsList(data,rangeEndNum=24,charCountLen=2):
list2 = []
for i in range(1,rangeEndNum+1):
right=charCountLen*(rangeEndNum-i)
if type(data).__name__=='str':
data= int(data, 16)
x=data >> right
c=2**charCountLen
list2=[(x % c)]+list2
return abListMerge(list2)
# 采集压缩用
def zipSolarTermsList(inputList,charCountLen=2):
tempList=abListMerge(inputList, type=-1)
data=0
num=0
for i in tempList:
data+=i << charCountLen*num
num+=1
return hex(data),len(tempList)
def getTheYearAllSolarTermsList(year):
return unZipSolarTermsList(solarTermsData[year-START_YEAR])